45fan.com - 路饭网

搜索: 您的位置主页 > 网络频道 > 阅读资讯:怎么样在C#中使用SQLDMO的StoredProcedure对象?

怎么样在C#中使用SQLDMO的StoredProcedure对象?

2016-08-24 19:17:12 来源:www.45fan.com 【

怎么样在C#中使用SQLDMO的StoredProcedure对象?


.......
SQLDMO.StoredProcedure strProc = new SQLDMO.StoredProcedure();
// Assign a name to stored procedure
strProc.Name = "createCustomerTable";
// Write a Stored Procedure Script and pass it as a string.
strProc.Text = "CREATE procedure createCustomerTable as begin " +
"CREATE TABLE [ChangeMemberID] ([CusID] [int] NOT NULL ,[ChangeDate] [smalldatetime] NULL ,"+
"[MIDO] [varchar] (6) COLLATE Chinese_PRC_CI_AS NULL ,"+
"[MIDN] [varchar] (6) COLLATE Chinese_PRC_CI_AS NULL ) ON [PRIMARY] " +
"END";
// Add the Stored Procedure to Database
nDB.StoredProcedures.Add(strProc);
// Execute the stored procedure to create table
nDB.ExecuteImmediate("createCustomerTable", 0, 0);

/* Remove the stored procedure from database. The index starts from 1.*/
foreach (SQLDMO.StoredProcedure tmpSP in nDB.StoredProcedures)
{
//find the StoredProcedure named "createCustomerTable"
if (tmpSP.Name == "createCustomerTable")
{
nDB.StoredProcedures.Remove(tmpSP.ID, "");
break;
}
}


本文地址:http://www.45fan.com/a/question/67027.html
Tags: 存储 SQLDMO StoredProcedure
编辑:路饭网
关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部