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 |
What is difference between out and ref in c#?
Which controls do not have events?
How is the memory managed in C#.
How to assign Null value to Var?
What is the difference between as and is operators in c#?
What is ildasm and obfuscator in net?
What is string programming language?
What is the base class from which all value types are derived?
Why do we use reflection in c#?
Define thread?
How do I enforce const correctness in c#?
What can I create with 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)