为什么会出现此错误?这是什么意思?
执行第一个if语句,但程序停止并出现错误。
rowsource附带的值是小数
numericScale < NumericPrecision
语句应该有效。
if (((Type)rowSource["DataType"]).FullName == "System.Decimal")
{
// The default Decimal in SQL is decimal(18,0). Access does not show the number of decimals.
string dataType;
short numericScale;
if ((short)rowSource["NumericScale"] < (short)rowSource["NumericPrecision"])
{
// Access has rowSource["NumericScale"] = 255
if ((short)rowSource["NumericPrecision"] > 15)
{
// Use money as best guess
dataType = "money";
numericScale = 4;
}
else
{
dataType = "decimal";
numericScale = (short)rowSource["NumericPrecision"];
numericScale = Convert.ToInt16(numericScale/2);
}
}
else
{
dataType = "decimal";
numericScale = (short)rowSource["NumericScale"];
}
sb.Append(
objDbTarget.SqlColumnDefinition(
objDbTarget.ColumnNameEnclosed(colName),
dataType,
(int)rowSource["ColumnSize"],
(short)rowSource["NumericPrecision"],
numericScale,
(bool)rowSource["AllowDbNull"]
)
).Append(comma);
}
我发现当我在某处使用这段代码时代码会出错。
//if (objDbTarget.DbType != dbTypeEnum.Sqlite)
//{
// if (string.IsNullOrWhiteSpace(SchemaTarget))
// {
// SchemaTarget = "dbo";
// }
//}
但是当我不使用它时,代码会给我这个错误。
- $ exception {&#34; Query = \ r \ n \ r \ n \ nCREATE SCHEMA [] AUTHORIZATION [dbo] \ r \ nTimeout seconds = 30 \ r \ n \ nConnection string = Data Source = UTCD108938;连接超时= 30;集成安全性= SSPI \ r \ n_keepConnectionOpen = False,_beginTransaction = False&#34;}