-3
 SqlCommand cmd = new SqlCommand("UPDATE Records [First Name]='" + textBox2.Text + "',[Last Name]='" + textBox3.Text + "',[Middle Initial]='" + comboBox1.Text + "',Gender='" + comboBox2.Text + "',Address='" + textBox4.Text + "',Status='" + comboBox3.Text + "',Year='" + comboBox4.Text + "',Email='" + textBox5.Text + "',Course='" + comboBox5.Text + "',[Contact Number]='" + textBox6.Text + "'+     WHERE ([Student ID]='" + textBox1.Text + "')", con);
            cmd.ExecuteNonQuery();
            con.Close();
4

4 に答える 4

3

「セット」キーワードがありませんでした:

SqlCommand cmd = new SqlCommand("UPDATE Records SET [First Name]='" + textBox2.Text + "',[Last Name]='" + textBox3.Text + "',[Middle Initial]='" + comboBox1.Text + "',Gender='" + comboBox2.Text + "',Address='" + textBox4.Text + "',Status='" + comboBox3.Text + "',Year='" + comboBox4.Text + "',Email='" + textBox5.Text + "',Course='" + comboBox5.Text + "',[Contact Number]='" + textBox6.Text + "'+     WHERE ([Student ID]='" + textBox1.Text + "')", con);
            cmd.ExecuteNonQuery();
            con.Close();
于 2013-08-11T06:14:20.527 に答える
2

私はこれがあるべきだと信じています

SqlCommand cmd = new SqlCommand("UPDATE Records set [First Name]='" + textBox2.Text + "',[Last Name]='" + textBox3.Text + "',[Middle Initial]='" + comboBox1.Text + "',Gender='" + comboBox2.Text + "',Address='" + textBox4.Text + "',Status='" + comboBox3.Text + "',Year='" + comboBox4.Text + "',Email='" + textBox5.Text + "',Course='" + comboBox5.Text + "',[Contact Number]='" + textBox6.Text + "'+     WHERE ([Student ID]='" + textBox1.Text + "')", con);
            cmd.ExecuteNonQuery();
            con.Close();

違うのは「セット」という言葉

于 2013-08-11T06:14:31.620 に答える
0

更新クエリの構文が間違っています。「SET」キーワードを追加するのを忘れた可能性があります。

更新クエリの構文は次の場所にあります。 http://www.tutorialspoint.com/sql/sql-update-query.htm

SqlCommand cmd = new SqlCommand("UPDATE Records SET [First Name]='" + textBox2.Text + "',[Last Name]='" + textBox3.Text + "',[Middle Initial]='" + comboBox1.Text + "',Gender='" + comboBox2.Text + "',Address='" + textBox4.Text + "',Status='" + comboBox3.Text + "',Year='" + comboBox4.Text + "',Email='" + textBox5.Text + "',Course='" + comboBox5.Text + "',[Contact Number]='" + textBox6.Text + "'+     WHERE ([Student ID]='" + textBox1.Text + "')", con);
            cmd.ExecuteNonQuery();
            con.Close();
于 2013-08-11T06:21:35.580 に答える