本文介绍了附加信息:查询表达式'@phone no'中的语法错误(缺少运算符)。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 当我插入数据时,我收到这样的错误 附加信息:语法错误(缺少运算符) 查询表达式' @ Phone No '。 我的尝试: for ( int i = 0 ; i < dataGridView21.Rows.Count; i ++) { OleDbCommand command = new OleDbCommand(); command.Connection = connection; command.CommandText = @ 插入总计([Column1],[Column2],[Column3], [日期],[收据号码],[送货人],[报告],[口味],[姓名],[电话号码] VALUES(@ Column1,@ Column2,@ Column3,@ Date,@ ReceiptNo,@ DeliveryPerson,@ Report,@ Flavours,@ Name,@ Phone No); // values('+ dataGridView21.Rows [i] .Cells [0] .Value.ToString ()+','+ dataGridView21.Rows [i] .Cells [1] .Value.ToString()+','+ txtDisplay.Text +','+ label4.Text +', '+ label2.Text +','+ label128.Text +',+ dataGridView21.Rows [i] .Cells [0] .Value.ToString()+,'+ dataGridView21.Rows [i ] .Cells [3] .Value.ToString()+','+ dataGridView21.Rows [i] .Cells [5] .Value.ToString()+','+ dataGridView21.Rows [i]。 Cells [6] .Value.ToString()+');; connection.Open(); for ( int j = 0 ; j < dataGridView21.Rows.Count; j ++) { var row = dataGridView21.Rows [j]; 如果 (row.IsNewRow)继续; command.Parameters.Clear(); command.Parameters.AddWithValue( @ Column1,row.Cells [ 0 ]值)。 command.Parameters.AddWithValue( @ Column2,row.Cells [ 1 ]值)。 command.Parameters.AddWithValue( @ Column3,txtDisplay.Text); command.Parameters.AddWithValue( @ Date,label4.Text); command.Parameters.AddWithValue( @ ReceiptNo,label2.Text); command.Parameters.AddWithValue( @ DeliveryPerson,label128.Text); command.Parameters.AddWithValue( @ Report,row.Cells [ 0 ]值)。 command.Parameters.AddWithValue( @ Flavors,row.Cells [ 3 ]值)。 command.Parameters.AddWithValue( @ Name,row.Cells [ 5 ]值)。 command.Parameters.AddWithValue( @ Phone No,row.Cells [ 6 ]值); command.ExecuteNonQuery(); } connection.Close(); } // printreceiptod(); flpCategories.Enabled = false ; flpProducts.Enabled = false ; listBox20.Focus(); MessageBox.Show( 成功插入,dataGridView21.Rows.Count + + ITEMS,MessageBoxButtons.OK,MessageBoxIcon.Information); listBox20.Focus(); dataGridView21.Rows.Clear(); label128.Text = Delivery; while (listBox20.Items.Count > 0 ) { button64.PerformClick(); } flpCategories.Enabled = true ; } 解决方案 when i am insert data so i am getting an error like thisAdditional information: Syntax error (missing operator) in query expression '@Phone No'.What I have tried:for (int i = 0; i < dataGridView21.Rows.Count; i++) { OleDbCommand command = new OleDbCommand(); command.Connection = connection; command.CommandText = @"insert into Total ([Column1],[Column2],[Column3],[Date],[Receipt No],[Delivery Person],[Report],[Flavours],[Name],[Phone No]) VALUES(@Column1, @Column2, @Column3, @Date, @ReceiptNo, @DeliveryPerson, @Report, @Flavours, @Name , @Phone No)"; //values('" + dataGridView21.Rows[i].Cells[0].Value.ToString() + "','" + dataGridView21.Rows[i].Cells[1].Value.ToString() + "','" + txtDisplay.Text + "','" + label4.Text + "','" + label2.Text + "','" + label128.Text + "'," + dataGridView21.Rows[i].Cells[0].Value.ToString() + ",'" + dataGridView21.Rows[i].Cells[3].Value.ToString() + "','" + dataGridView21.Rows[i].Cells[5].Value.ToString() + "','" + dataGridView21.Rows[i].Cells[6].Value.ToString() + "');"; connection.Open(); for (int j = 0; j < dataGridView21.Rows.Count; j++) { var row = dataGridView21.Rows[j]; if (row.IsNewRow) continue; command.Parameters.Clear(); command.Parameters.AddWithValue("@Column1", row.Cells[0].Value); command.Parameters.AddWithValue("@Column2", row.Cells[1].Value); command.Parameters.AddWithValue("@Column3", txtDisplay.Text); command.Parameters.AddWithValue("@Date", label4.Text); command.Parameters.AddWithValue("@ReceiptNo", label2.Text); command.Parameters.AddWithValue("@DeliveryPerson", label128.Text); command.Parameters.AddWithValue("@Report", row.Cells[0].Value); command.Parameters.AddWithValue("@Flavours", row.Cells[3].Value); command.Parameters.AddWithValue("@Name", row.Cells[5].Value); command.Parameters.AddWithValue("@Phone No", row.Cells[6].Value); command.ExecuteNonQuery(); } connection.Close(); } //printreceiptod(); flpCategories.Enabled = false; flpProducts.Enabled = false; listBox20.Focus(); MessageBox.Show("Inserted Sucessfully", dataGridView21.Rows.Count + " " + "ITEMS", MessageBoxButtons.OK, MessageBoxIcon.Information); listBox20.Focus(); dataGridView21.Rows.Clear(); label128.Text = "Delivery"; while (listBox20.Items.Count > 0) { button64.PerformClick(); } flpCategories.Enabled = true; } 解决方案 这篇关于附加信息:查询表达式'@phone no'中的语法错误(缺少运算符)。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-27 13:03