关于怎么写类
我写咯一个关于登陆的类,但是总是出错,请高手指点
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;
}
}
}
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;
}
}
}
...全文
相关推荐
javascript写类方式之六
本文将深入探讨“javascript写类方式之六”,并结合标签“源码”和“工具”,解析其中的原理与实践。
C#关于类的只读只写属性实例分析
这种情况下,即使在类的内部也必须遵循只读或只写的规则。这种方式在C#3.0和更高版本中,利用自动实现的属性使属性声明更加简洁。
Python中关于自己写类的基础代码
Python中关于自己写类的基础代码,Python中关于自己写类的基础代码,Python中关于自己写类的基础代码,Python中关于自己写类的基础代码,Python中关于自己写类的基础代码。
自用写日志类
针对C++开发者来说,一个高效、稳定且线程安全的日志类是十分重要的工具。本文介绍的日志类“自用写日志类”即是在这样的背景下产生的。
这是一个写日志类,可用于实际项目开发应用。
本文将详细解析标题为“这是一个写日志类,可用于实际项目开发应用。”的压缩包文件中涉及的关键知识点:写日志类、队列以及报错级别。首先,我们来讨论“写日志类”。


