i need to insert data into sql server table emp through
textboxes txtname and txtsalary using c# code. Please help
Answer / 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 |
If a child class instance is created, which class constructor is called first - base class or child class?
What is difference between property and variable in c#?
What are the advantages of clr procedure over t-sql procedure?
Is c# lazy thread safe?
Why is it a bad idea to throw your own exceptions?
Why should you override the tostring() method?
What is the Difference between a sub and a function?
Explain constructor?
How to find methods of a assembly file (not using ILDASM)?
What is literal in c#?
Is static class thread safe in c#?
What is difference between variable and property in c#?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)