存储过程:
create procedure AddAdmin
(
@type varchar(50),
@username varchar(50),
@password varchar(50)
)
as
declare @exeSql varchar(500)
if @type='RegisteEnteInfo'
begin
set @exeSql='insert into admin values
('''+@username+''','''+@password+''')'
exec(@exeSql)
end
public void ApplicantAdd(string Name, string Password) //添加用户信息
{
DMClass dmCls = new DMClass();
SqlDataReader dr = null;
SqlParameter[] param = {
dmCls.CreateInParam("@type",SqlDbType.VarChar,50,"RegisteEnteInfo"),
dmCls.CreateInParam("@username",SqlDbType.VarChar,50,Name ),
dmCls.CreateInParam("@password",SqlDbType.VarChar,50,Password)
};
dmCls.RunProc("AddAdmin", param, out dr);
}
protected void Button1_Click(object sender, EventArgs e)
{
Ente en = new Ente();
string username = this.TextBox1.Text.ToString();
string password = this.TextBox2.Text.ToString();
try
{
en.ApplicantAdd(username, password);
Response.Write("<script>alert('注册成功');</script>");
}
catch (Exception ex)
{
Response.Write("<script>alert('注册失败');</script>");
}
}