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
Write down the c# syntax to catch an exception
Explain the role of Garbage collector and its generations?
What is difference between web and window application?
What is application object in c#?
What are the concepts of dispose method?
What are the main reasons to use c# language?
What is literal control
If a child class instance is created, which class constructor is called first - base class or child class?
What is thread pooling?
How to update the gui from another thread in c#?
Explain the different types of delegates used in c#.
Can a method return multiple values in c#?
What is executereader in c#?
How do I register my code for use by classic com clients?
Describe two uses of the “using” statement during the operation of c#?