一、使用存储过程:
SqlConnection conn = new SqlConnection(CommonDB.ConnectionString);
SqlCommand cmd = new SqlCommand("P_Employee_Check", conn);
cmd.Parameters.Add("@EmployeeCode", header.Username);
cmd.Parameters.Add("@EmployeePassword", header.Password);
cmd.Parameters.Add("@ReturnValue",-1) ;
cmd.Parameters["@ReturnValue"].Direction = ParameterDirection.ReturnValue ;
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
iRet = Convert.ToInt32(cmd.Parameters["@ReturnValue"].Value) ;
SqlConnection conn = new SqlConnection(CommonDB.ConnectionString);
SqlCommand cmd = new SqlCommand("P_Employee_Check", conn);
cmd.Parameters.Add("@EmployeeCode", header.Username);
cmd.Parameters.Add("@EmployeePassword", header.Password);
cmd.Parameters.Add("@ReturnValue",-1) ;
cmd.Parameters["@ReturnValue"].Direction = ParameterDirection.ReturnValue ;
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
iRet = Convert.ToInt32(cmd.Parameters["@ReturnValue"].Value) ;