MySQL + .net + EF 开发环境,调用一处sql语句报错:
Fatal error encountered during command execution
[sql] view plain copy print?
SELECT @r AS cateid,(SELECT @r := b.ParentId FROM cmscontentcategory b WHERE b.id = cateid) AS parentid
FROM (SELECT @r := ‘75422ccd151c484291013d72f9a98cd7‘) vars,cmscontentcategory h
WHERE @r <> ‘sys‘;
查看详细错误:
Parameter ‘@r‘ must be defined
查看国外资料发现一个方法,在mysql数据连接字符串增加Allow User Variables=True
Database=testdb;Data Source=localhost;User Id=root;Password=hello;Allow User Variables=True
ok,搞定。
时间: 2024-11-05 01:39:57