【发布时间】:2016-05-23 14:00:47
【问题描述】:
我有一个插入查询,我试图将 table1 数据复制到 table2。现在,当我直接在 MySQL 中执行但尝试通过 VB.Net 进行调试时,Query 工作正常"
INSERT INTO newMedicinesOrders (`OrderID`,`medicineName`, `power`, `form`, `fQuantity`, `iQuantity`, `type`, `cost`, `prescriptionLink`, `userID`) SELECT `orderID`, `name`, `power`, `form`, `fQuantity`, `iQuantity`, `type`, `mrp`, `prescriptionLink`, `userID` from myCart WHERE userID = '1'
我收到一条错误消息
“字段列表”中的未知列“orderID”
vb代码
Try
Dim str1 As String = "INSERT INTO newMedicinesOrders (`OrderID`,`medicineName`, `power`, `form`, `fQuantity`, `iQuantity`, `type`, `cost`, `prescriptionLink`, `userID`) SELECT `orderID`, `name`, `power`, `form`, `fQuantity`, `iQuantity`, `type`, `mrp`, `prescriptionLink`, `userID` from myCart WHERE userID = '" + userid.Text + "'"
Dim str2 As MySqlDataReader
Dim adapter As New MySqlDataAdapter
Dim command As New MySqlCommand
command.CommandText = str1
command.Connection = con
adapter.SelectCommand = command
con.Open()
str2 = command.ExecuteReader
con.Close()
Response.Write("<script language='javascript'>alert('Success.');</script>")
Catch ex As Exception
Response.Write(ex)
End Try
【问题讨论】:
-
@eggyal 它将扩展消息显示为“'字段列表'中的未知列'orderID'”
-
我们能看到在 vb.net 中调用这个查询的代码吗?
-
@eggyal 我给你看调试模式截图可以吗?
-
最好将代码复制/粘贴到您的问题中,但如果有信息只能在屏幕截图中传达,那么请务必这样做。
-
不确定这是否会有所不同,但是您能否将值 1 硬编码到 .net 中以查看它是否可行,因为这是唯一的区别?