我得到 oledb 异常未处理,我找不到它发生的原因,谁能帮我记下它
i BOLD 和斜体错误代码
并且异常显示如下查询表达式'Product Name =''Chair''中的语法错误(缺少运算符)。
谢谢
导入 System.Data.OleDb 公开课形式1 '声明可验证的 将 itemName 调暗为字符串 Dim itemprice, average, rows, index, totalPrice 将 foundItem 调暗为布尔值 Dim conctionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\Education\BIT\Assainment\L1S2\VB\Assesment 2\Stock.accdb" 暗淡阅读器作为 OleDbDataReader Dim olDataConnection 作为新的 OleDbConnection(connectionString) Dim olCommand 作为 OleDbCommand Private Sub Form1_Load(ByVal sender As System.Object, e As EventArgs) 处理 MyBase.Load '将数据加载到组合框 总价格 = 0 行 = 0 '开始连接 olDataConnection.Open() olCommand = New OleDbCommand("SELECT * FROM Stock", olDataConnection) 阅读器 = olCommand.ExecuteReader() 而(阅读器。读取()) comDataStock.Items.Add(DirectCast(reader("Product Name"), String) & "-Rs." & DirectCast(reader("Price"), Integer) & " /= ") totalPrice = totalPrice + DirectCast(reader("Price"), Integer) 行 = 行 + 1 结束时 尝试 平均值 = totalPrice / 行 lblAverResult.Text = "卢比。" & average.ToString() & " /=" 抓住前任作为例外 MessageBox.Show("Somethingg Wrong", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information) 结束尝试 olDataConnection.Close() 结束子 Private Sub btnDelete_Click(sender As Object, e As EventArgs) 处理 btnDelete.Click olDataConnection.Open() olCommand = New OleDbCommand("DELETE FROM Stock WHERE Product Name=''" & comDataStock.SelectedItem.ToString().Split("-").GetValue(0).ToString() & "'", olDataConnection) 阅读器 = olCommand.ExecuteReader() olDataConnection.Close() comDataStock.Items.Clear() 总价格 = 0 行 = 0 olDataConnection.Open() olCommand = (New OleDbCommand("SELECT FROM Stock ", olDataConnection)) 阅读器 = olCommand.ExecuteReader() 而(阅读器。读取()) comDataStock.Items.Add(DirectCast(reader("Price"), String) & "-Rs." & DirectCast(reader("Price"), Integer) & " /= ") totalPrice = totalPrice + DirectCast(reader("Price"), Integer) 行 = 行 + 1 结束时 尝试 平均值 = totalPrice / 行 lblAverResult.Text = "Rs." & average.ToString() & " /=" 抓住前任作为例外 MessageBox.Show(ex.ToString()) 结束尝试 olDataConnection.Close() 结束子 结束类