//例子
create database sky
use sky
create table employee(income float,income2 float,allincome float)
//建立存储过程
create proc Empprocduce @a float,@b float as insert into employee values(@a,@b,@a+@b)
create proc Empprocduce @a float,@b float as insert into employee values(@a,@b,@a+@b)
exec Empprocduce @a=10,@b=30
drop proc Empprocduce
select * from employee
select * from employee
//调用存储过程
SqlConnection con = new SqlConnection("server=.;uid=sa;pwd=;database=sky");
con.Open();
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandText = "Empprocduce";//调用存储过程
com.CommandType = CommandType.StoredProcedure;
com.Parameters.Add("@a",SqlDbType.Float );//添加
com.Parameters.Add("@b",SqlDbType.Float );
com.Parameters["@a"].Value = 10;//赋值
com.Parameters["@b"].Value = 20;
com.ExecuteNonQuery();