如何写?是用 static 的方法还是  非static方法如何返回
谢谢

解决方案 »

  1.   

    public string Login(string userName, string password) {
    string customerID; // params to stored proc
    Database data = new Database();
    SqlParameter[] prams = {
    data.MakeInParam("@username",    SqlDbType.VarChar, 25, password),
    data.MakeInParam("@password",    SqlDbType.VarChar, 25, userName),
    data.MakeOutParam("@CustomerID", SqlDbType.VarChar, 25)
    }; // create data object and params
    data.RunProc("upAccountLogin", prams);    // run the stored procedure
    customerID = (string) prams[2].Value;     // get the output param value // if the customer id is an empty string, then the login failed
    if (customerID == string.Empty)
    return null;
    else
    return customerID;
    }
      

  2.   

    public int RunProc(string procName) {
    SqlCommand cmd = CreateCommand(procName, null);
    cmd.ExecuteNonQuery();
    this.Close();
    return (int)cmd.Parameters["ReturnValue"].Value;
    }
    private SqlCommand CreateCommand(string procName, SqlParameter[] prams) {
    // make sure connection is open
    Open(); //command = new SqlCommand( sprocName, new SqlConnection( ConfigManager.DALConnectionString ) );
    SqlCommand cmd = new SqlCommand(procName, con);
    cmd.CommandType = CommandType.StoredProcedure; // add proc parameters
    if (prams != null) {
    foreach (SqlParameter parameter in prams)
    cmd.Parameters.Add(parameter);
    }

    // return param
    cmd.Parameters.Add(
    new SqlParameter("ReturnValue", SqlDbType.Int, 4,
    ParameterDirection.ReturnValue, false, 0, 0,
    string.Empty, DataRowVersion.Default, null)); return cmd;
    }
      

  3.   

    调用:
       你的工程名.你的类库名.类里面的方法名(参数)除了把LOGIN写到类里,把登录框做成用户控件也挺方便,方便每个页面调用.