关于怎么写类
我写咯一个关于登陆的类,但是总是出错,请高手指点
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写类方式之六
NULL 博文链接:https://snandy.iteye.com/blog/416686
C#关于类的只读只写属性实例分析
主要介绍了C#关于类的只读只写属性实例分析,对于初学者更好的理解类的只读只写属性有一定的帮助,需要的朋友可以参考下
Python中关于自己写类的基础代码
Python中关于自己写类的基础代码,Python中关于自己写类的基础代码,Python中关于自己写类的基础代码,Python中关于自己写类的基础代码,Python中关于自己写类的基础代码。
自用写日志类
自己写的一个非常简单方便的日志类, 内附VS2013的演示工程, 演示程序为单cpp标准C++文件, 可用其他编译器编译运行. 线程安全.
这是一个写日志类,可用于实际项目开发应用。
这是一个写日志类,可用于实际项目开发应用。实现原理是创建一个队列,然后将日子字符串不断加入队列,启动一个线程将队列中的字符串写入日志文件,可以设置报错级别


