0

我使用 MySql.Data.MySqlClient.MySqlCommand 和 MySqlConnection

Public fillGridCmdTxt As String = "SELECT tblItems.part_num AS Part#, tblCategory.category_description AS Category, " _
            & " tblItems.item_name AS 'Item Name', tblItems.item_desc AS Description, " _
            & "tblItems.item_qty AS Qty, tblUnit.unit_name AS Unit, tblItems.item_price AS 'Selling Price(Php)' " _
            & "FROM tblUnit INNER JOIN tblItems ON tblUnit.unit_id = tblItems.unit_id INNER JOIN tblCategory " _
            & "ON tblItems.category_id = tblCategory.category_id "

当我在 MySqlCommand 上使用 executeNonQuery 时,它给了我一个错误......它说“ Unkown table '* tblItems in field list *”即使该表确实存在于我的数据库中......请帮忙?

4

1 回答 1

0

您需要用Part#引号括起来。

#符号在 MySQL 中开始注释,因此您的整个语句被读取为SELECT tblItems.part_num AS Part. 错误消息告诉您,您在字段列表中命名了一个您未在列表中指定的FROM表(因为该FROM列表已被注释掉)。

于 2013-09-15T10:34:03.807 回答