SQLDMO.SQLServer2 svr = new SQLDMO.SQLServer2Class();
svr.Connect(ServerName, UserName, Password);
SQLDMO.Database2 myDb = new SQLDMO.Database2Class();
myDb = (SQLDMO.Database2)svr.Databases.Item(DatabaseName, "owner");
SQLDMO.Table2 myTb = new SQLDMO.Table2Class();
foreach (SQLDMO.Table2 tb in myDb.Tables)
{
if (tb.Name == TableName)
myTb = tb;
}
SQLDMO.Column2 cm = (SQLDMO.Column2)myTb.Columns.Item(ColumnName);修改成为varchar,nvarchar类型的时候
cm.AlterDataType("Numeric",9,9, 3); 成功修改为int的时候
cm.AlterDataType("int",4,9, 0); 出错到底 AlterDataType方法修改字段为int类型的时候,怎样的参数才可以??
svr.Connect(ServerName, UserName, Password);
SQLDMO.Database2 myDb = new SQLDMO.Database2Class();
myDb = (SQLDMO.Database2)svr.Databases.Item(DatabaseName, "owner");
SQLDMO.Table2 myTb = new SQLDMO.Table2Class();
foreach (SQLDMO.Table2 tb in myDb.Tables)
{
if (tb.Name == TableName)
myTb = tb;
}
SQLDMO.Column2 cm = (SQLDMO.Column2)myTb.Columns.Item(ColumnName);修改成为varchar,nvarchar类型的时候
cm.AlterDataType("Numeric",9,9, 3); 成功修改为int的时候
cm.AlterDataType("int",4,9, 0); 出错到底 AlterDataType方法修改字段为int类型的时候,怎样的参数才可以??
objectExpression that evaluates to an object in the Applies To listDataTypeString that specifies the new data typeLengthOptional long integer that specifies the length of a string data typePrecisionOptional long integer that specifies the precision of a numeric data typeScaleOptional long integer that specifies the scale of a numeric data type.Prototype (C/C++)HRESULT AlterDataType(
SQLDMO_LPCSTR DataType,
long Length,
long Precision,
long Scale);ResWhen using AlterDataType to convert the data type of an existing column to a new data type, the two data types must be compatible. For example, an int data type can be converted to a decimal data type, and a char data type can be converted to an nvarchar data type. However string data types cannot be converted to numeric data types.
试试 cm.AlterDataType("int");
--
字符型不能转换数值型报的什么错?