关于怎么写类

panzi667 panzi667 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我写咯一个关于登陆的类,但是总是出错,请高手指点

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;
}
}


}
...全文

相关推荐

评论 8
收藏 已收藏
分享
返回顶部
panzi667
.NET社区 62,271 成员 668,968 内容