i m not able to change precision of numeric datatype with SMO
I have created table using SMO object and i want to change precision of numeric datatype. Sometimes it gets changed but sometimes it is not and also do not generate any error.
Specially when i debug my code numeric precision do not change.
this is how i created my table
Code:string connectionString = "Data Source = Server; Integrated Security = SSPI;"; SqlConnection connection = new SqlConnection(connectionString); server = new Server(new ServerConnection(connection)); Database db; db = server.Databases["Testing"]; Table mdtnewTable = new Table(db, "Testing0"); Column ColId = new Column(mdtnewTable, "Code0"); ColId.DataType = DataType.Numeric(0, 5); ColId.Nullable = false; Column ColId1 = new Column(mdtnewTable, "Code1"); ColId1.DataType = DataType.VarChar(50); ColId1.Nullable = false; Column ColName = new Column(mdtnewTable, "Name0"); ColName.DataType = DataType.VarChar(50); ColNameS.Nullable = false; mdtnewTable.Columns.Add(ColId); mdtnewTable.Columns.Add(ColId1); mdtnewTable.Columns.Add(ColName); mdtnewTable.Create();
here is my code to change numeric precision
when i change numeric precision from 10 to any integer number say 15 and if i run my application without debugging than it's working fine. but when i debug it, it fails without giving any error message. There is no primary keyCode:mdtnewTable = db.Tables["Testing0"]; Column ColId1 = mdtnewTable.Columns["Code0"]; ColId1.DataType = DataType.Numeric(0,10); ColId1.Nullable = false; mdtnewTable.Alter();
or any other contraints defined on this table
Plz help me![]()


Reply With Quote