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
what is inheritance and an example in vb.net and c# of when you might use it?
Explain why do I get an error (cs1006) when trying to declare a method without specifying a return type?
How do you escape c#?
What is the difference between do and while loop?
What do constructors do in c#?
Why singleton is sealed?
What is a collection in c#?
What is the difference between Static, Const and read only?
Enlist all the components of an ado.net framework?
What is the difference between static and constant variables?
What is the difference between static class and singleton class in c#?
What is “using” statement in c#?
Is there an equivalent to the instanceof operator in visual j++?
hi my question is about understanding a text the user entered to a site , so i want to analyse that text looking for some specific items such as "honda" "shoffere" etc.. so if this site could help or could tell me where to go with such question ,i wonder. thanks
Why do we use interface in c#?