关于怎么写类
我写咯一个关于登陆的类,但是总是出错,请高手指点
public int ht_login(string username,string userpass,string state)
{
string connectionString = ConfigurationManager.AppSettings["conn"];
using (OleDbConnection connection1 = new OleDbConnection(connectionString))
{
try
{
connection1.Open();
OleDbCommand command1 = new OleDbCommand();
command1.CommandText = "select * from cont_user where user_id=? and user_pwd=? and user_go=?";
OleDbParameter parameter1 = new OleDbParameter("@user_id", OleDbType.LongVarChar, 50);
parameter1.Direction = ParameterDirection.Input;
OleDbParameter parameter2 = new OleDbParameter("@user_pwd", OleDbType.LongVarChar, 50);
parameter2.Direction = ParameterDirection.Input;
OleDbParameter parameter3 = new OleDbParameter("@user_state", OleDbType.LongVarChar, 50);
parameter3.Direction = ParameterDirection.Input;
command1.Parameters.Add(parameter1);
command1.Parameters.Add(parameter2);
command1.Parameters.Add(parameter3);
parameter1.Value = username;
parameter2.Value = userpass;
parameter3.Value = state;
command1.Connection = connection1;
Int32 count = (Int32)command1.ExecuteNonQuery();
return count;
}
catch (Exception ex)
{
string ErrMsg = ex.Message.Replace("\n", "");
connection1.Close();
return -1;
}
}
}