使用smo创建索引时出错 [英] error in creating index with smo
本文介绍了使用smo创建索引时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友,我要在数据库中创建包含sal,age等不同列的索引.
无法创建索引"Id_Index".我的代码是
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();
}
请帮助我
please help me
推荐答案
我得到了答案
如果表已准备就绪,则创建而不是
table td = new table(db,"QRDH1");
使用
表td = db.tables ["QRDHQ1"];
I got the answer
if table is all ready created the instead of
table td=new table(db,"QRDH1");
use
table td=db.tables["QRDHQ1"];
这篇关于使用smo创建索引时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文