protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(); con.ConnectionString = "MY CONNECTION STRING GOES HERE"; con.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "insert into Registration (Name) values (" + Convert.ToString(TextBox2.Text) + ")"; cmd.CommandType = CommandType.Text; cmd.Connection = con; //cmd.ExecuteNonQuery(); DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); con.Close(); }
Single quotes
cmd.CommandText = "insert into Registration (Name) values ('" +Convert.ToString(TextBox2.Text)+ "')";
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)