繁体   English   中英

使用C#在MYSQL中声明局部变量时发生致命错误

[英]Fatal Error Occurs while declaring Local variable in MYSQL using C#

在MYSQL中声明局部变量时出现异常。 请建议我如何解决此问题。

例外:
命令执行期间遇到致命错误。
的InnerException:
{"Parameter '@OrderofParent' must be defined."}

代码段:

   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; ");

在连接字符串参数中添加"Allow User Variables=True"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM