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

Helo , Help Me , Help Me About : C# Windows Application - Network How To Manage IP Client's Accessiblity To The Internet Share concise Substitute , Minor ISA Server

0 Answers  


Define Abstract Class in C#

0 Answers   HCL,


What does break do in loop?

0 Answers  


What is strongly typed in c#?

0 Answers  


What does the keyword virtual mean in the method definition?

1 Answers  






Explain manifest in c#.

0 Answers  


List the difference between interface and abstract class?

0 Answers  


What is boxing in c#?

0 Answers  


How do I port "synchronized" functions from visual j++ to c#?

0 Answers  


What are the differences between system.string and system.text.stringbuilder classes?

0 Answers  


Who benefits from ajax?

0 Answers  


What is manifest ?

3 Answers   Digital GlobalSoft,


Categories