参数化查询的问题
参数化查询 '(@username nvarchar(50),@userpwd nvarchar(50),@usersex nchar(2),' 需要参数 @userhead,但未提供该参数。代码如下: = "insert into userinfo(username,userpwd,usersex,userhead,userphone,useremail,userdiploma) values(@username,@userpwd,@usersex,@userhead,@userphone,@useremail,@userdiploma)";
cmd.Parameters.Add("@username", SqlDbType.NVarChar, 50);
cmd.Parameters.Add("@userpwd", SqlDbType.NVarChar, 50);
cmd.Parameters.Add("@usersex", SqlDbType.NChar, 2);
cmd.Parameters.Add("@userhead", SqlDbType.NVarChar, 0);
cmd.Parameters.Add("@userphone", SqlDbType.NChar, 11);
cmd.Parameters.Add("@useremail", SqlDbType.NVarChar, 50);
cmd.Parameters.Add("@userdiploma", SqlDbType.NChar, 10);
cmd.Parameters["@username"].Value = txtUserName.Text;
cmd.Parameters["@userpwd"].Value = txtUserPwd.Text;
cmd.Parameters["@usersex"].Value = this.Rabsex.Text;
cmd.Parameters["@userhead"].Value = savePath;
cmd.Parameters["@userphone"].Value = this.txtUserPhone.Text;
cmd.Parameters["@useremail"].Value = this.txtEmail.Text + this.libEmail.SelectedItem.Text.ToString();
cmd.Parameters["@userdiploma"].Value = this.libdiploma.SelectedItem.Text.ToString();