1、新建一个Sql Server Project
2、写存储过程,C#示意代码如下:
1
[SqlProcedure]
2 public 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}
2 public 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了。
本文转自Jack Niu博客园博客,原文链接:http://www.cnblogs.com/skywind/archive/2007/03/02/661180.html,如需转载请自行联系原作者