i need to insert data into sql server table emp through
textboxes txtname and txtsalary using c# code. Please help



i need to insert data into sql server table emp through textboxes txtname and txtsalary using c# co..

Answer / suresh

open the Sqlconnection and write the connection string dere
and take one sqldata Adapter and also take one datatable
write the following code.

sqlconnection con=new sqlconnection("server=.; user Id=sa;
Password=sa123; Database=emp");
sqlDataAdapter da;
DataTable dt;

In Button Click Event you write this code

da=new sqlDataAdapter("insert into Emp(EmpID,Ename) values
('"+textbox1.Text+"','"+textbox2.Text+"'",con);
dt=new DataTable();
da.Fill(dt);


That's it you entered the Data into SQL Server

Is This Answer Correct ?    5 Yes 1 No

Post New Answer

More C Sharp Interview Questions

What is the max value of int32 in c#?

0 Answers  


What's new in c#?

0 Answers  


What is function c#?

0 Answers  


What is the difference between dynamic and var in c#?

0 Answers  


Why do we use delegates?

0 Answers  






What is the difference between static and private constructor in c#?

0 Answers  


Explain the feature of c# language?

0 Answers  


What is difference between destructor and finalize?

0 Answers  


What is the use of "default" and "Using" keyword?

3 Answers   TCS,


Why ref is used in c#?

0 Answers  


Explain how to implement an object pool in c#.net

0 Answers  


What is the default modifier for class in c#?

0 Answers  


Categories