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 master page in asp net c#?

0 Answers  


What is the main usage of keyword “virtual” ? How does it work for a method or property?

0 Answers   Siebel,


Can abstract class be sealed?

0 Answers  


Is array a list?

0 Answers  


What is the function of the not null constraint?

0 Answers  


What is difference between field and property in c#?

0 Answers  


What is difference between write and writeline?

0 Answers  


How can you read 3rd line from a text file?

0 Answers  


Is constructor a static method?

0 Answers  


Does C# support multiple inheritance?

5 Answers  


How to open a new form on button click in Windows forms?

0 Answers   Viscus Infotech,


What are indexers in c# .net?

0 Answers  


Categories