{
STDB.Open();
string query = $"INSERT INTO [dbo].[Inbound](Trailer#, Shipper#,
Seal#, Recieved By, Recieving Shift, Carrier, Supplier, Vendor,
Contents, Location, Comments) VALUES ('{textBox1.Text}',
'{textBox2.Text}','{textBox3.Text}', '{comboBox5.Text}',
'{comboBox1.Text}','{comboBox6.Text}', '{textBox4.Text}',
'{textBox5.Text}',' {comboBox2.Text}', '{comboBox3.Text}',
'{textBox6.Text}')";
SqlDataAdapter SDA = new SqlDataAdapter(query, STDB);
SDA.SelectCommand.ExecuteNonQuery();
STDB.Close();
MessageBox.Show("Done");
}
(这是来自编辑器的填充文本,因为这篇文章最初只是作为代码发布但没有代码格式,我编辑了代码,使其至少对其他人更具可读性)< / p>
答案 0 :(得分:0)
你不希望经过。您希望在by中的第一个字段之后执行命令。如果列的名称周围有空格,则字段名称为[]
{ STDB.Open(); string query = $"INSERT INTO [dbo].[Inbound](Trailer#, Shipper#, Seal#, Recieved By [Recieving Shift], Carrier, Supplier, Vendor, Contents, Location, Comments)