System.Data.OleDb.OleDbCommand cmd = null;//comand
System.Data.OleDb.OleDbDataReader rd =null; //reader
string strSql = "select * from t_gbit_login where c_id='"+strID.Trim()+"'"; try
{
cmd = new System.Data.OleDb.OleDbCommand(strSql,oleConn);
rd=cmd.ExecuteReader();
if(rd.Read())
{
strName=rd["c_name"].ToString().Trim();
strSex=rd["c_sex"].ToString().Trim();
strRight=rd["c_right"].ToString().Trim();
strPwd=rd["c_pwd"].ToString().Trim();
iRows++;
}
}
catch(System.Exception eee)
{
strErrorMsg="查询身份验证信息失败,错误信息:"+eee.Message;
return false;
}
finally
{
rd.Close();
cmd.Dispose();
oleConn.Close();
}
System.Data.OleDb.OleDbDataReader rd =null; //reader
string strSql = "select * from t_gbit_login where c_id='"+strID.Trim()+"'"; try
{
cmd = new System.Data.OleDb.OleDbCommand(strSql,oleConn);
rd=cmd.ExecuteReader();
if(rd.Read())
{
strName=rd["c_name"].ToString().Trim();
strSex=rd["c_sex"].ToString().Trim();
strRight=rd["c_right"].ToString().Trim();
strPwd=rd["c_pwd"].ToString().Trim();
iRows++;
}
}
catch(System.Exception eee)
{
strErrorMsg="查询身份验证信息失败,错误信息:"+eee.Message;
return false;
}
finally
{
rd.Close();
cmd.Dispose();
oleConn.Close();
}
这个也不对,rd的数据库的记录,不能使用Trim();,直接ToString()就够了
连接sybase数据才产生的问题
执行到rd.Close();不卡死了
连接到sybase12.5的时候,数据也能查出来,就是卡死到rd.Close()那里了,
只有把网络断开,它才会向下执行
catch再过滤的细点
System.Data.OleDb.OleDbDataReader rd =null; //reader
string strSql = "select * from t_gbit_login where c_id='"+strID.Trim()+"'";try
{
cmd = new System.Data.OleDb.OleDbCommand(strSql,oleConn);
rd=cmd.ExecuteReader();
while(rd.Read())
{
strName=rd["c_name"].ToString().Trim();
strSex=rd["c_sex"].ToString().Trim();
strRight=rd["c_right"].ToString().Trim();
strPwd=rd["c_pwd"].ToString().Trim();
iRows++;
}
rd.Close();
}
catch(System.Exception eee)
{
strErrorMsg="查询身份验证信息失败,错误信息:"+eee.Message;
return false;
}
finally
{
try
{
cmd.Dispose();
oleConn.Close();
}
catch
{}
}