i need to insert data into sql server table emp through
textboxes txtname and txtsalary using c# code. Please help
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 |
What is master page in asp net c#?
What is the main usage of keyword “virtual†? How does it work for a method or property?
Can abstract class be sealed?
Is array a list?
What is the function of the not null constraint?
What is difference between field and property in c#?
What is difference between write and writeline?
How can you read 3rd line from a text file?
Is constructor a static method?
Does C# support multiple inheritance?
How to open a new form on button click in Windows forms?
What are indexers in c# .net?