Error in creating index with smo
hi friends I am going to create index on my database which contains different column like sal,age.But i got an error failedoperationexception error in index creation.
fail to create index "Id_Index".my code is
SqlConnection con = new SqlConnection(@"Data Source=MAHESH-F7B2934C\BABA;Initial Catalog=te;Integrated Security=True;Pooling=True");
ServerConnection sc = new ServerConnection(con);
Server srv = new Server(sc);
try{
Database db = srv.Databases["te"];
Table tb = new Table(db, "QRHDQ1");
if (tb != null)
{
Index id = new Index(tb, "Id_index");
id.IndexKeyType = IndexKeyType.DriPrimeryKey;
IndexedColumn indexedcol = new IndexedColumn(id, "id",true);
id.IndexedColumns.Add(indexedcol);
id.IsClustered = true;
id.Create();
}