gpt4 book ai didi

c# - 使用 C# 在 MYSQL 中声明局部变量时发生 fatal error

转载 作者:行者123 更新时间:2023-11-29 13:14:44 27 4
gpt4 key购买 nike

我在 MYSQL 中声明局部变量时遇到异常。请建议我如何解决这个问题..

异常:
命令执行期间遇到 fatal error 。
内部异常:
{“必须定义参数'@OrderofParent'。”}

代码片段:

   StringBuilder sbQuery = new StringBuilder(); <br>
sbQuery.Append(@"Declare @OrderofParent INT; SET @OrderofParent = 0;
select top 1 @OrderofParent = OrderofParent from Filter group by OrderofParent order by OrderofParent desc;

select 'FamilyType' as Mode, 0 as Id, 'Complexity Type' as FilterName, null as FilterCreatedDate, 0 as IsDisabled,0 as ParentId, @OrderofParent as OrderofParent,1 as TagDisplay, 0 as ParentCount from I_FamilyTypePrice
union
Select 'Filter', Id, FilterName, FilterCreatedDate, IsDisabled, f.ParentId, OrderofParent, TagDisplay, 0 from Filter f where f.ParentID = 0
union
select 'FamilyType', ft.Id, FamilyTypeName, CreatedDate, 0,0, @OrderofParent,0, count(complexityType) from I_FamilyTypePrice ft join Family f on f.complexityType = ft.Id where version = @version and IsActive = 1 and Uploaded = 1; ");

最佳答案

添加“允许用户变量=True”在连接字符串参数中

关于c# - 使用 C# 在 MYSQL 中声明局部变量时发生 fatal error ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21619164/

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