最近优化某项目数据库(MS SQLServer),原字段是varchar(32),存储内容为GUID字符串,改为uniqueidentifier类型,默认值newid()。
之后程序运行发现异常:对象必须实现 IConvertible。
调试BUG后发现问题出现在ParameterInfo.AddParameter("@id", DbType.Guid, drTestResultQt["id"]);
改为ParameterInfo.AddParameter("@id", DbType.Guid, drTestResultQt["id"]);问题解决。
SqlDbType => DbType | |
SqlDbType.BigInt | DbType.Int64 |
SqlDbType.Binary | DbType.Binary |
SqlDbType.Bit | DbType.Boolean |
SqlDbType.Char | DbType.AnsiStringFixedLength |
SqlDbType.DateTime | DbType.DateTime |
SqlDbType.Decimal | DbType.Decimal |
SqlDbType.Float | DbType.Double |
SqlDbType.Image | DbType.Binary |
SqlDbType.Int | DbType.Int32 |
SqlDbType.Money | DbType.Currency |
SqlDbType.NChar | DbType.StringFixedLength |
SqlDbType.NText | DbType.String |
SqlDbType.NVarChar | DbType.String |
SqlDbType.Real | DbType.Single |
SqlDbType.UniqueIdentifier | DbType.Guid |
SqlDbType.SmallDateTime | DbType.DateTime |
SqlDbType.SmallInt | DbType.Int16 |
SqlDbType.SmallMoney | DbType.Currency |
SqlDbType.Text | DbType.AnsiString |
SqlDbType.Timestamp | DbType.Binary |
SqlDbType.TinyInt | DbType.Byte |
SqlDbType.VarBinary | DbType.Binary |
SqlDbType.VarChar | DbType.AnsiString |
SqlDbType.Variant | DbType.Object |
SqlDbType.Xml | DbType.Xml |
SqlDbType.Udt | DbType.Object |
SqlDbType.Structured | DbType.Object |
SqlDbType.Date | DbType.Date |
SqlDbType.Time | DbType.Time |
SqlDbType.DateTime2 | DbType.DateTime2 |
SqlDbType.DateTimeOffset | DbType.DateTimeOffset |
DbType => SqlDbType | |
DbType.AnsiString | SqlDbType.VarChar |
DbType.Binary | SqlDbType.VarBinary |
DbType.Byte | SqlDbType.TinyInt |
DbType.Boolean | SqlDbType.Bit |
DbType.Currency | SqlDbType.Money |
DbType.Date | SqlDbType.DateTime |
DbType.DateTime | SqlDbType.DateTime |
DbType.Decimal | SqlDbType.Decimal |
DbType.Double | SqlDbType.Float |
DbType.Guid | SqlDbType.UniqueIdentifier |
DbType.Int16 | SqlDbType.SmallInt |
DbType.Int32 | SqlDbType.Int |
DbType.Int64 | SqlDbType.BigInt |
DbType.Object | SqlDbType.Variant |
DbType.Single | SqlDbType.Real |
DbType.String | SqlDbType.NVarChar |
DbType.Time | SqlDbType.DateTime |
DbType.AnsiStringFixedLength | SqlDbType.Char |
DbType.StringFixedLength | SqlDbType.NChar |
DbType.Xml | SqlDbType.Xml |
DbType.DateTime2 | SqlDbType.DateTime2 |
DbType.DateTimeOffset | SqlDbType.DateTimeOffset |