关于数据查询的一个问题!!!!!!!!
String sqlconn = "User ID=sa;pwd=qq;Data Source=.;Initial Catalog=shaosjm;Provider=SQLOLEDB.1;Trusted_Connection=no ";
OleDbConnection myConnection = new OleDbConnection(sqlconn);
OleDbConnection myConnection1 = new OleDbConnection(sqlconn);
myConnection.Open();
myConnection1.Open();
string sql = "select * from users where riqi=(select max(riqi) from users) ";
string sql1 = "select count(*) as sum1 from users ";
OleDbCommand myCommand = new OleDbCommand(sql, myConnection);
OleDbCommand myCommand1 = new OleDbCommand(sql1, myConnection1);
OleDbDataReader my;
OleDbDataReader my1;
my=myCommand.ExecuteReader();
my1=myCommand1.ExecuteReader();
if(my.Read())
{
Session[ "na "]=my[ "name "];
Session[ "n "]=my1[ "sum1 "];
}
else
{
Response.Redirect( "Login.aspx ");
}
我想通过上面的语句返回两个值,调试一直说”Session[ "n "]=my1[ "sum1 "];““不存在此行/列的数据”。
不明白,请给指出问题所在。
------解决方案--------------------if(my.Read()&&my1.Read())
------解决方案--------------------my1没有read