c# 调用 存储过程
来源:互联网 发布:网络诈骗的七大特点 编辑:程序博客网 时间:2024/05/22 14:41
SQL
-------------------------------------------------------------
alter proc fact
@a int,@b int output
as
declare @tem nvarchar(10)
begin
if exists(select empName from employee where empName='郭金亮' )
begin
insert into employee values('1234567891','有了',1,'32020002')
set @tem='有了'
end
else
begin
insert into employee values('9876543211','郭金亮',0,'32020002')
set @tem='郭金亮'
end
select @b=ID from employee where empName=@tem
end
------------------
C#
------------------------------------------------------
SqlConnection con = new SqlConnection("server=.;database=hospital;uid=sa;pwd=123;");
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
int a=0;
cmd.CommandText = "fact";
cmd.Parameters.Add("@a", SqlDbType.Int);
cmd.Parameters["@a"].Value = 10;
cmd.Parameters.Add("@b", SqlDbType.Int);
cmd.Parameters["@b"].Direction = ParameterDirection.Output;
con.Open();
cmd.ExecuteNonQuery();
Console.WriteLine(cmd.Parameters["@b"].Value.ToString());
con.Close();
Console.ReadLine();
- C#调用存储过程
- C#调用存储过程
- C#调用存储过程
- C#调用存储过程
- C#调用存储过程
- C# 调用存储过程
- c# 调用存储过程
- C#调用存储过程
- c# 调用 存储过程
- C# 调用存储过程
- C#调用存储过程
- C#调用存储过程
- C#调用存储过程
- C#调用存储过程
- C#调用存储过程
- C# 调用存储过程
- C# 调用存储过程
- C# 调用存储过程
- MYSQL 你知道mysql中union的语法么?
- ARGB 值详解
- jsp:格式化页面时间显示格式
- Csharp 讀寫文件內容搜索自動彈出 AutoCompleteMode
- Ubuntu MySQL安装指南
- c# 调用 存储过程
- MYSQL 介绍一下mysql的常用基本命令
- IOS真机调试error launching remote program failed to get the task 解决方案
- Csharp 讀寫文件內容搜索自動彈出 AutoCompleteMode
- 单文档应用程序切换视图
- PowerDesigner笔记
- maven实战笔记-2
- android 图表引擎
- JQM List