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
What is unrecognized escape sequence in c#?
What is the difference between finally and finalize block?
Explain About a class access specifiers and method access specifiers.
What are the advantages of constructor?
If you define a user defined data type by using the struct keyword, is it a value type or reference type?
What is a byte in c#?
What are managed providers?
What is difference between write and writeline in c#?
What do you mean by default constructor?
What is semaphore in c#?
What is difference between const and static in c#?
Why singleton class is sealed in c#?
Which control cannot be placed in mdi?
what is object-oriented programming (oop) language?
What is difference between string and stringbuilder in c#?