iwant для вставки в базу данных, но я получаю эту ошибку, которая говорит «синтаксическая ошибка рядом с таблицей ключевых слов». Обратите внимание, что таблица ключевых слов - это имя таблицы, в которой я хочу чтобы данные накладок .. , что случилось с моим кодом кто может помочь ...Синтаксис Ошибки при попытке вставить в базу данных
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
try
{
byte[] imageData = ReadFile(textBox8.Text);
da.InsertCommand = new SqlCommand("insert into Table values(@NationalID,@FirstName,@MiddleName,@LastName,@DateOfBirth,@Gender,@Address,@HomeTown,@StateOfOrigin,@MaritalStatus,@JobStatus,@ImagePath,@Image)", cn);
da.InsertCommand.Parameters.Add("NationalID", SqlDbType.VarChar).Value = textBox1.Text;
da.InsertCommand.Parameters.Add("FirstName", SqlDbType.VarChar).Value = textBox2.Text;
da.InsertCommand.Parameters.Add("MiddleName", SqlDbType.VarChar).Value = textBox3.Text;
da.InsertCommand.Parameters.Add("LastName", SqlDbType.VarChar).Value = textBox4.Text;
da.InsertCommand.Parameters.Add("DateOfBirth", SqlDbType.VarChar).Value = dateTimePicker1.Value;
da.InsertCommand.Parameters.Add("Gender", SqlDbType.VarChar).Value = comboBox4.Text;
da.InsertCommand.Parameters.Add("Address", SqlDbType.VarChar).Value = textBox5.Text;
da.InsertCommand.Parameters.Add("HomeTown", SqlDbType.VarChar).Value = textBox6.Text;
da.InsertCommand.Parameters.Add("StateOfOrigin", SqlDbType.VarChar).Value = comboBox1.Text;
da.InsertCommand.Parameters.Add("MaritalStatus", SqlDbType.VarChar).Value = comboBox2.Text;
da.InsertCommand.Parameters.Add("JobStatus", SqlDbType.VarChar).Value = comboBox3.Text;
da.InsertCommand.Parameters.Add("ImagePath", SqlDbType.VarChar).Value = textBox8.Text;
da.InsertCommand.Parameters.Add(new SqlParameter("@Image", (object)imageData));
//da.InsertCommand.Parameters.Add("@Image", SqlDbType.Image).Value = pictureBox1.Image;
cn.Open();
da.InsertCommand.ExecuteNonQuery();
cn.Close();
Вот почему ** вы никогда не называете таблицы 'table' **. Вам нужно указать/избежать этого. –