gpt4 book ai didi

c# - 动态 SQL 错误 SQL 错误代码 = -104 token 未知

转载 作者:行者123 更新时间:2023-11-30 23:07:22 26 4
gpt4 key购买 nike

这里是错误:

Dynamic SQL Error    
SQL error code = -104
Token unknown - line 1, column 162
VALUE

代码如下:

using (FbDataAdapter da = new FbDataAdapter(@"SELECT DOC_ITEMS.ID, PRODUCTS.PRODUCTKEY, PRODUCTS.NAME, DOC_ITEMS.QUANTITY, UNITS.UNIT, DOC_ITEMS.PRICE, DOC_ITEMS.TAX, (DOC_ITEMS.PRICE * DOC_ITEMS.QUANTITY) AS VALUE
FROM PRODUCTS INNER JOIN
DOC_ITEMS ON PRODUCTS.PRODUCTID = DOC_ITEMS.PRODUCTID INNER JOIN
UNITS ON PRODUCTS.UNITID = UNITS.UNITID
WHERE (DOC_ITEMS.DOCUMENTID = @DocumentID)", con))

{
da.SelectCommand.Parameters.AddWithValue("@DocumentID", documentId);

DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;

dataGridView1.Columns["PRODUCTKEY"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
dataGridView1.Columns["ID"].Visible = false;
dataGridView1.Columns["NAME"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns["QUANTITY"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
dataGridView1.Columns["QUANTITY"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
dataGridView1.Columns["UNIT"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
dataGridView1.Columns["PRICE"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
dataGridView1.Columns["PRICE"].DefaultCellStyle.Format = "0.00 $";
dataGridView1.Columns["TAX"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
dataGridView1.Columns["TAX"].DefaultCellStyle.Format = "0\\%";
dataGridView1.Columns["VALUE"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
dataGridView1.Columns["VALUE"].DefaultCellStyle.Format = "0.00 $";
}

当我直接通过我的数据库运行这个命令时,它工作正常,但在我的 C# 代码中它会丢弃这个错误。

最佳答案

使用带双引号的 ""VALUE"",因为一个引号将关闭您的字符串。

关于c# - 动态 SQL 错误 SQL 错误代码 = -104 token 未知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47376121/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com