VSTS 2005 写SQL Server存储过程基础 (C#)
VSTS 2005 写SQL Server存储过程(Procedue)
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

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

3、配置该Project的DataBase连接属性
4、部署(Deploy):项目点右键,选择Deploy
5、到SqlServer中看看把,已经有你的Procedue了。
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步