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
How will you deploy the dll file in gac?
what will be the output of the given below coding. using System; public class Exercise { static void OddNumbers(int a) { if (a >= 1) { Console.Write("{0}, ", a); a -= 2; OddNumbers(a); } } public static int Main() { const int Number = 9; Console.WriteLine("Odd Numbers"); OddNumbers(Number); Console.WriteLine(); return 0; } }
What is the use of functional interface?
Why would you use a class property in c#?
What is append in c#?
What is the difference between int.parse and int.tryparse methods?
What is namespace c#?
Should I use double or float?
What is a statement c#?
What is callback in c#?
Why do we need to call CG.SupressFinalize?
Which of the following operations can you not perform on an ado.net dataset?
What are the properties of string?
What is the difference between c and c sharp?
What is private variable?