注册

【DmProvider】DmCommand查询中使用Guid类型参数报错不支持Guid转换。(“not support this GUID cast”)

DM_360065 2022/12/14 2261 3

【DM版本】:DM8(–03134283938-20221019-172201-20018)
【操作系统】:windows 10 64位
【CPU】:i5-10500
【问题描述】*:
【DmProvider】DmCommand查询中使用Guid类型参数报错不支持Guid转换。(System.InvalidCastException:“not support this GUID cast”)
参考另一个提问:https://eco.dameng.com/community/question/f6c7aa7d869fd673c438c9e7926abbc8
版本:DmProvider.1.1.0.11058
现象:
image.png
示例代码

var sql = @"SELECT :UserId FROM DUAL;"; using (var connection = new DmConnection(s_connectionString)) { connection.Open(); IDbCommand command = connection.CreateCommand(); command.CommandText = sql; var param = command.CreateParameter(); param.ParameterName = ":UserId"; param.DbType = DbType.Guid; param.Value = Guid.NewGuid(); command.Parameters.Add(param); var reader = command.ExecuteReader(); Read(reader); }

堆栈信息:

System.InvalidCastException
  HResult=0x80004002
  Message=not support this GUID cast
  Source=DmProvider
  StackTrace:
   在 Dm.DmCommand.BindParameters(Int32& rowCount, DmDataReader rd, CommandBehavior behavior)
   在 Dm.DmCommand.do_ExecuteDbDataReader(CommandBehavior behavior)
   在 Dm.DmCommand.ExecuteDbDataReader(CommandBehavior behavior)
   在 System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
   ...
回答 0
暂无回答
扫一扫
联系客服