다음은 데이터베이스에 데이터를 추가하는 코드입니다. 이 코드를 실행하면이 C# 코드가 내 데이터베이스에 행을 추가하지 못하는 이유는 무엇입니까?
try
{
String id = txtId.Text;
String name = txtName.Text;
String tel = txtTel.Text;
String add = txtAdd.Text;
String SqlQuery = @"INSERT INTO [Table]
VALUES(@id, @name, @tell, @add)";
using (SqlConnection con = new SqlConnection(conString))
using (SqlCommand cmnd = new SqlCommand(SqlQuery, con))
{
con.Open();
cmnd.Parameters.Add("@id", SqlDbType.NVarChar).Value = id;
cmnd.Parameters.Add("@name", SqlDbType.NVarChar).Value = name;
cmnd.Parameters.Add("@tel", SqlDbType.NVarChar).Value = tel;
cmnd.Parameters.Add("@add", SqlDbType.NVarChar).Value = add;
cmnd.ExecuteNonQuery();
MessageBox.Show("Saved Sucessfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error occurred while saving", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
, 나는이 같은 오류 메시지가 표시되는 이유는 무엇
@tell 스칼라 변수를 선언해야 오류 메시지
이있다? 코드가 잘못 되었나요? 이 문제를 해결할 수 있도록 도와 주시겠습니까?
이
은 내가 오류 메시지입니다 :