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

Button(<<<)

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.

button_click()
{
          sqlConnection con= new sqlconnection("//your db path");
          sqldataAdapter da=new sqldataAdapter("select * from table_details",con);
            DataSet ds=new DataSet();
            da.fill(ds,"table_details");
            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;
            ds.Tables["Table_Details"].Rows.Add(dr);
            da.Update(ds, "Table_Details");
 


}

let me know whether u understand or not?

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

This question has already been answered. Start a new discussion instead.