Loading ...

SQL | CodeAsp.Net

  • aryary2010

    I have got 5 textboxes, button and customers table within my database.

    I want when customers inplement the data that going into database automatic.


    can someone help to do that

  •   Answered

    Can you please be more specific? Are you trying to insert the data that is coming from the textbox to the database? If so then you can do something like this using the ADO.NET way:

    public string GetConnectionString()
        return System.Configuration.ConfigurationManager.ConnectionStrings["ConnStringName"].ConnectionString; 
       //sets the connection string from your web config file "ConnString" is the name of your Connection String
    private void InsertInfo()
           SqlConnection conn = new SqlConnection(GetConnectionString());
           string sql = "INSERT INTO connect_com (name,E_mail,School ) VALUES (@Val1,@Val2,@Val3)";
               SqlCommand cmd = new SqlCommand(sql, conn);
               cmd.Parameters.AddWithValue("@Val1", txtName.Text);
               cmd.Parameters.AddWithValue("@Val2", txtEmail.Text);
               cmd.Parameters.AddWithValue("@Val3", txtSchool.Text);
               cmd.CommandType = CommandType.Text;
           catch (System.Data.SqlClient.SqlException ex)
                    string msg = "Insert Error:";
                    msg += ex.Message;
                    throw new Exception(msg);
    protected void Button1_Click(object sender, EventArgs e)

    You can also refer to the link below for another example:

    Creating a Simple Registration Form in ASP.NET

    Vincent Maverick Durano, MVP
  • timcadieux

    More Tutorials here as well

    Visit my site at the EveryManProgrammer.com
  • Page 1 of 1 (3 items)