c#中的登录过程,输入用户名和密码后点击登录按钮利用存储过程来判断是否合法用户。
编译正常,按F5运行后输入用户和密码后点击登录后出现如下错误:未处理的System.Data.SqlClient.SqlException类型的异常出现在system.data.dll
其它信息System error.存储过程如下:CREATE Procedure Get_loginname
(
    @login_name nvarchar(20),
    @login_password nvarchar(20),
    @return_number int OUTPUT,
    @dep_id int output,
    @permit_id int output,
    @description nvarchar(60) output 
)
AS
    select login_name from employees where login_name=@login_name
    if (@@Rowcount<1)
      begin
        set @return_number=0
        set @description='Sorry,Wrong Login Name,Please Try Again.'
      end
    else
      begin
        SELECT login_name,login_password,dep_id,permit_id
        FROM employees 
        where login_name =@login_name and login_password=@login_password
        IF (@@Rowcount < 1)
         BEGIN
           SET @return_number = 0
           set @description='Sorry,Wrong Password,Please Try Again.'
         END
      else
         BEGIN
          SET @return_number = 1
         set @description='Access.'
       END
    endreturn
GOLOGIN.CS中相关代码如下:private void btn_login_Click(object sender, System.EventArgs e)
{
getconnected();
this.DialogResult=DialogResult.OK;
this.Close(); 
} public void getconnected()
{
int dep_id;
string str_conn="server=localhost;database=hrmis;uid=sa;pwd=;";
SqlConnection myConnection=new SqlConnection(str_conn);
myConnection.Open();
SqlCommand mycommand=new SqlCommand("Get_loginname",myConnection);
mycommand.CommandType=CommandType.StoredProcedure;
mycommand.Parameters.Add(new SqlParameter("@login_name",SqlDbType.NVarChar));
mycommand.Parameters.Add(new SqlParameter("@login_password",SqlDbType.NVarChar));
mycommand.Parameters.Add(new SqlParameter("@dep_id",SqlDbType.Int,4,ParameterDirection.Output,false,0,0,"dep_id",DataRowVersion.Default,null)); mycommand.Parameters["@login_name"].Value = txt_password.Text.ToString();
mycommand.Parameters["@login_pasword"].Value = txt_password.Text.ToString();

mycommand.ExecuteNonQuery();
dep_id=(int)mycommand.Parameters["@dep_id"].Value;
myConnection.Close();
}