Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Write down the c# syntax to catch an exception

938


Explain the role of Garbage collector and its generations?

954


What is difference between web and window application?

851


What is application object in c#?

934


What are the concepts of dispose method?

945


What are the main reasons to use c# language?

954


What is literal control

1018


If a child class instance is created, which class constructor is called first - base class or child class?

929


What is thread pooling?

969


How to update the gui from another thread in c#?

991


Explain the different types of delegates used in c#.

942


Can a method return multiple values in c#?

864


What is executereader in c#?

906


How do I register my code for use by classic com clients?

890


Describe two uses of the “using” statement during the operation of c#?

961