HI i am getting error on lbl.Visible = true and command.ExecuteNonQuery();

plz check and paste correct coding i doing new project plz help me.

  protected void Button1_Click1(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection("Data Source=RAVI-PCSQLEXPRESS;Initial Catalog=personals;User ID=sa;password=sa;Integrated Security=True");
            SqlDataAdapter da = new SqlDataAdapter(" select * from table_2", conn);
            DataSet ds = new DataSet();
            da.Fill(ds, "table_1");

            conn.Open(); 

            SqlCommand command = new SqlCommand();

            command.CommandText = ("insert into table_1 (id,name,address,phone,city)values(@id,@name,@address,@phone,@city");
            command.Parameters.Add("@id", SqlDbType.VarChar, 50);
            command.Parameters.Add("@name", SqlDbType.VarChar, 50);
            command.Parameters.Add("@address", SqlDbType.VarChar, 50);
            command.Parameters.Add("@phone", SqlDbType.VarChar, 50);
            command.Parameters.Add("@city", SqlDbType.VarChar, 50);

            command.Parameters["@id"].Value = TextBox1.Text;
            command.Parameters["@name"].Value = TextBox2.Text;
            command.Parameters["@address"].Value = TextBox3.Text;
            command.Parameters["@phone"].Value = TextBox4.Text;
            command.Parameters["@city"].Value = TextBox5.Text;

            lbl.Visible = true;

            command.ExecuteNonQuery();
             conn.Close();

        }

You haven't told us the error (which helps us for future reference) but I'm going to say the command object isn't working because you haven't provided it with the connection object. Do this with

command.Connection = conn;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.