复制代码 代码如下:
create proc proc_addUserInfo
@uname varchar(50),
@upass varchar(50),
@Returnc int output
as
begin
insert into erp_user(u_name,u_pass)values(@uname,@upass)
set @Returnc= isnull(@@identity,0)
end
复制代码 代码如下:
SqlParameter[] para = new SqlParameter[]
{
new SqlParameter("@uname","2012"),
new SqlParameter("@upass","2012")
};
string sql_para = "dbo.proc_addUserInfo";
CommandType type=CommandType.StoredProcedure;
SQLHelper sqlh = new SQLHelper();
int Id=sqlh.ExecuteNoQuery(sql_para,type,para);
复制代码 代码如下:
public int ExecuteNoQuery(string sql,CommandType type,params SqlParameter [] values)
{
using (SqlCommand cmd = new SqlCommand(sql, Conn))
{
cmd.CommandType = type;
if (values != null)
{
cmd.Parameters.AddRange(values);
}
SqlParameter Retvar = cmd.Parameters.Add("@Returnc", SqlDbType.Int);
Retvar.Direction = ParameterDirection.Output;
int count = cmd.ExecuteNonQuery();
return (int)Retvar.Value;
}
}
新闻热点
疑难解答
图片精选