i need to insert data into sql server table emp through
textboxes txtname and txtsalary using c# code. Please help
Answer Posted / 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 View All Answers
List the two important objects of ado.net and also list the namespaces that are commonly used in ado.net to aid in connection to a database.
What is the example of predicate?
Are c# objects passed by reference?
What is check/uncheck?
Why do we need constructor?
What is using keyword?
Write a C# program to find the Factorial of n
What is the main method in c#?
Why do we use class in c#?
Explain what is the smallest unit of execution in .net?
What is gridview c#?
What's different between c# and c/c++?
What is the do while loop code?
What is a .aspx file?
What is thread and explain states of a thread in c#?