gpt4 book ai didi

c# - 获取插入项的ID

转载 作者:太空狗 更新时间:2023-10-30 00:39:56 24 4
gpt4 key购买 nike

<分区>

所以我有这样的查询:

cmd.CommandText = @"INSERT INTO [dbo].[bill](bruto, waiterid, reversalid, number, ddate, tableid, total, printed, posplace, guestid, numberofguests, closedtime, methodofpaymentid, realdate) " +
"VALUES (@bruto, @waiterid, 0, 0, @ddate, 1, @total, 'True', 0, 0, 0, @closedtime, @methodofpaymentid, @realtime) " +
"SELECT id";
//+ lines of cmd.Parameter.AddWithValue(...,...);

但是一旦我尝试使用以下命令执行查询:

int newId = Convert.ToInt64(cmd.ExecuteScalar());

我知道 id 未被识别(即使它确实存在)。

如果我尝试将 SELECT 更改为 [dbo].[bill].id,我会收到错误

The multi-part identifier "dbo.bill.id" could not be bound.

我也试过让它成为 SELECT MAX(id)(因为这是最接近标量的东西),但我又一次遇到了无法识别的错误。

感谢阅读。

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