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


Please Help Members By Posting Answers For Below Questions

What is unrecognized escape sequence in c#?

503


What is the difference between finally and finalize block?

507


Explain About a class access specifiers and method access specifiers.

531


What are the advantages of constructor?

448


If you define a user defined data type by using the struct keyword, is it a value type or reference type?

514






What is a byte in c#?

548


What are managed providers?

542


What is difference between write and writeline in c#?

480


What do you mean by default constructor?

605


What is semaphore in c#?

506


What is difference between const and static in c#?

487


Why singleton class is sealed in c#?

505


Which control cannot be placed in mdi?

523


what is object-oriented programming (oop) language?

478


What is difference between string and stringbuilder in c#?

456