You must Sign In to post a response.
  • Category: ASP.NET

    Insert data to sql server using asp.net

    Dear All,

    I am new to asp.net. Any one please give me the step by step process to insert data from asp.net to sqlserver.


    Regards,
    Salim.
  • #756953
    Hi

    Step1 Establish your Connectionstring Like this
    add this code your webconfig

    <add name="ConnectionString" connectionString="Data Source=YOURPCNAME;Initial Catalog=TEST;
    Integrated Security=True;providerName="System.Data.SqlClient"/>

    Step2
    =====
    Pass your Insert query to db via commandtext or storedprocedure

    Refer my article this url
    http://www.dotnetspider.com/resources/43345-How-To-Insert-Update-Delete-using.aspx


    also refer this

    http://www.codeproject.com/Tips/763172/Insert-Data-Using-Stored-Procedure-in-ASP-NET
    http://www.c-sharpcorner.com/UploadFile/0c1bb2/inserting-from-data-into-database-using-stored-procedure-in/
    http://www.aspnettutorials.com/tutorials/database/storedprocedure-csharp/

    Name : Dotnet Developer-2015
    Email Id : kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #756954
    Hi saleem,

    Refer below link here I explain how to insert data into database with simple example. dotnetspider.com/resources/45044-Call-Stored-Procedure-Application.aspx

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #756955
    Refer the below code for insert data into sql table using dot net.


    SqlConnection Conn = new SqlConnection(YourConnectionString);
    SqlDataAdapter da = new SqlDataAdapter();
    da.InsertCommand = new SqlCommand("INSERT INTO TableName VALUES(@Col1,@Col2,@Col3,@Col4,@Col5)", Conn);
    da.InsertCommand.Parameters.Add("@Col1", SqlDbType.VarChar).Value = textBox1.Text;
    da.InsertCommand.Parameters.Add("@Col2", SqlDbType.VarChar).Value = textBox2.Text;
    da.InsertCommand.Parameters.Add("@Col3", SqlDbType.Int).Value = textBox3.Text;
    da.InsertCommand.Parameters.Add("@Col4", SqlDbType.Int).Value = textBox4.Text;
    da.InsertCommand.Parameters.Add("@Col5", SqlDbType.Int).Value = textBox5.Text;
    Conn.Open();
    da.InsertCommand.ExecuteNonQuery();
    Conn.Close();


  • Sign In to post your comments