现在的位置: 首页 > 综合 > 正文

VSTS 2005 写SQL Server存储过程基础 (C#)

2013年01月01日 ⁄ 综合 ⁄ 共 634字 ⁄ 字号 评论关闭
VSTS 2005 写SQL Server存储过程(Procedue)
1、新建一个Sql Server Project
2、写存储过程,C#示意代码如下:
 1[SqlProcedure]
 2public static void BackupDatabase(string strDatabaseName, string strFilePath)
 3{
 4 using(SqlConnection conn = new SqlConnection("context connection=true"))
 5 {
 6  try
 7  {
 8   // Procedure here.  e.g.
 9   // string strSQLCmd = "your command here";
10   // conn.Open();
11   // SqlCommand cmd = new SqlCommand(strSQLCmd, conn);
12   // cmd.ExecuteNonQuery();
13  }

14  catch (Exception ex)
15  {
16   // Exception here
17  }

18  finally
19  {
20   conn.Close();
21  }

22 }

23}
3、配置该Project的DataBase连接属性
4、部署(Deploy):项目点右键,选择Deploy
5、到SqlServer中看看把,已经有你的Procedue了。

抱歉!评论已关闭.