Hello everybody!
I'm doing my project about ASP.NET but i don't know how to Insert Data into Database.
First name: xxxxxxx
Last name: xxxxxxx


i want to know how the code working when i click the Button the data first name and last name will go to Database. I'm using SQL database.
Thanks for helping me.

hi you need to write the connectionstring first which is used to establish a connection between your database and application.

create a db with table name as table_details and fields as fname, lname with varchar type.

Let us take two textboxes with id text_first and text_last.
in button_click event you need to write the following code.

          sqlConnection con= new sqlconnection("//your db path");
          sqldataAdapter da=new sqldataAdapter("select * from table_details",con);
            DataSet ds=new DataSet();
            dataRow dr;
            SqlCommandbuilder cmd=new sqlcommandbuilder(da);
            dr = ds.Tables["Table_details"].NewRow();
            daInsert.Fill(ds, "Table_Details");

            dr["fname"] = text_first.Text;      
            dr["lname"] = text_last.Text;
            da.Update(ds, "Table_Details");


let me know whether u understand or not?

thanks a lot. I will try rite now.

If your problem is solved please mark it as solved.....

how do we insert data record from front end to back end. am using visual studio as front and toad as back end