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
Can we make a Static Constructor Parameterized? Give Reason with your answer
What language do desktop applications use?
What is the difference between a function and a method?
What is a dll in c#?
Can we change static variable value in c#?
Define MSIL, and how does it works? Why our developers need an appreciation of it if at all?
What is the difference between list and array in c#?
Why do we use void in c#?
Can abstract class have constructor?
What are the methods in c#?
What are accessors?
Can you inherit multiple classes in c#?
Explain the clr triggers?
What is the difference between inheritance and abstract class?
What is the CTS, and how does it relate to the CLS?