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
Which program construct must return a value?
What is datagrid c#?
What is an escape sequence in c#?
What is super class in c#?
Write a console application and implement the ternary operator to decide whether the age a user entered after being prompted is allowed to vote or not(given that only citizens between 18 and 120 years only inclusive can vote). Use exception handling for non-numerical input.
What is boxing? Explain its functionality?
update data in an xml file which resides in solution itself, using silverlight 4.0
What is difference between class and interface in c#?
What will a loop recorder show?
Are c and c# the same thing?
Is it possible to nest cfml conditional tags?
Enlist some of the properties of a thread class?
Define an array?
What does clr stand for?
What is the difference between Static, Const and read only?