Discuz!NT 论坛同步注册

来源:百度知道 编辑:UC知道 时间:2024/05/22 12:36:29
存储过程:
CREATE PROCEDURE dnt_createuserweb
@username nchar(20),
@password char(32),
@email char(50)
AS
DECLARE @uid int

INSERT INTO [dnt_users]([username], [password], [email]) VALUES(@username, @password, @email)
GO

调用:
cmd = new SqlCommand();
cmd.CommandText = @"dnt_createuserweb ";//这里是你要调用的存储过程名称
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@username", SqlDbType.Char,20).Value = TextBox1.Text;//给存储过程传参数
cmd.Parameters.Add("@password", SqlDbType.Char,32).Value = FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox2.Text, "MD5");
cmd.Parameters.Add("@email", SqlDbType.Char,32).Value = TextBox4.Text;

报错:输入字符串的格式不正确。
该怎么解决啊,帮个忙看看

总觉得cmd.CommandType = CommandType.StoredProcedure;
这样的调用很麻烦唉,后面还要设置很多参数

试试直接cmd.CommandText ="exec dnt_createuserweb 参数"
这样的,不过最好过滤下参数,没有做过注入测试