保存到数据库时出现错误(未处理...)

时间:2019-01-11 00:24:35

标签: c#

private void btnSave_Click(object sender, EventArgs e)
{
    Koneksi();
    cmd = new SqlCommand($"insert into Student values ('{txtName.Text}','{txtSex.Text}','{txtClassLevel.Text}','{txtAddress.Text}','{txtEmail.Text}','{txtPhone.Text}','{txtReligion.Text}','{txtParentName.Text}','{txtStatus.Text}')", con);

    cmd.ExecuteNonQuery(); [1]error image(http://prntscr.com/m5m4j3)
    con.Open();
                           [2]error image(http://prntscr.com/m5m59o)

    txtName.Clear();
    txtSex.Clear();
    txtClassLevel.Clear();
    txtAddress.Clear();
    txtEmail.Clear();
    txtPhone.Clear();
    txtReligion.Clear();
    txtParentName.Clear();
    txtStatus.Clear();
    MessageBox.Show($"Data {txtName.Text} berhasil Ditambah ^_^ ", "Registrasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

0 个答案:

没有答案