// Insert Simple Input protected void Button1_Click(object sender, EventArgs e) { MySqlConnection mySql = new MySqlConnection(); mySql.CreateConn(); mySql.Command = mySql.Connection.CreateCommand(); mySql.Command.CommandText = "insert into try1 (Fname, Lname, age) values ('Bill','Smith',56);"; mySql.Command.ExecuteNonQuery(); mySql.Command.Dispose(); mySql.Connection.Close(); mySql.CloseConn(); }
// Insert Simple Input protected void Button1_Click(object sender, EventArgs e) { MySqlConnection mySql = new MySqlConnection(); mySql.CreateConn(); mySql.Command = mySql.Connection.CreateCommand(); mySql.Command.CommandText = "insert into try1 (Fname, Lname, age) values ('Bill','Smith',56);"; mySql.Command.ExecuteNonQuery(); mySql.Command.Dispose(); mySql.Connection.Close(); mySql.CloseConn(); }
// Insert more complicated Input protected void Button2_Click(object sender, EventArgs e) { MySqlConnection mySql = new MySqlConnection(); mySql.CreateConn(); mySql.Command = mySql.Connection.CreateCommand(); String sqlInsert = "insert into try1 (Fname, Lname, age) values ('" + fName.Text + "','" + lName.Text + "'," + age.Text + ");"; Response.Write(sqlInsert); mySql.Command.CommandText = sqlInsert; mySql.Command.ExecuteNonQuery(); mySql.Command.Dispose(); mySql.Connection.Close(); mySql.CloseConn(); }
// Insert more complicated Input protected void Button2_Click(object sender, EventArgs e) { MySqlConnection mySql = new MySqlConnection(); mySql.CreateConn(); mySql.Command = mySql.Connection.CreateCommand(); String sqlInsert = "insert into try1 (Fname, Lname, age) values ('" + fName.Text + "','" + lName.Text + "'," + age.Text + ");"; Response.Write(sqlInsert); mySql.Command.CommandText = sqlInsert; mySql.Command.ExecuteNonQuery(); mySql.Command.Dispose(); mySql.Connection.Close(); mySql.CloseConn(); }