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

    Insert data to sql server using

    Dear All,

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

  • #756953

    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"/>

    Pass your Insert query to db via commandtext or storedprocedure

    Refer my article this url

    also refer this

    Name : Dotnet Developer-2015
    Email Id :

    '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.

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

    Blog :

  • #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;

  • Sign In to post your comments