经检测,就是这个程序段出了问题,请各位指点:public string strConn;
public string strSql;
public string strPath="Server.MapPath("./data/access/db.mdb")";
public string strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strPath;
public void Page_Load(object sender, System.EventArgs e)
{
if(IsPostBack){}
OleDbConnection OleConn=new OleDbConnection(strConn);
strSql="select * from Special";
OleDbCommand OleCmd=new OleDbCommand(strSql,OleConn);
OleCmd.Connection.Open();
OleDbDataReader OleDr=OleCmd.ExecuteReader(CommandBehavior.CloseConnection);
ListItem listitem1;
string strtemp;
while(OleDr.Read()){
strtemp=OleDr.GetString(2);//此处要用该列的索引位置
listitem1=new ListItem(strtemp,strtemp);
thematic.Items.Add(listitem1);
}
OleDr.Read();
OleConn.Close();
newstime.Text=DateTime.Now.ToString();
}
public string strSql;
public string strPath="Server.MapPath("./data/access/db.mdb")";
public string strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strPath;
public void Page_Load(object sender, System.EventArgs e)
{
if(IsPostBack){}
OleDbConnection OleConn=new OleDbConnection(strConn);
strSql="select * from Special";
OleDbCommand OleCmd=new OleDbCommand(strSql,OleConn);
OleCmd.Connection.Open();
OleDbDataReader OleDr=OleCmd.ExecuteReader(CommandBehavior.CloseConnection);
ListItem listitem1;
string strtemp;
while(OleDr.Read()){
strtemp=OleDr.GetString(2);//此处要用该列的索引位置
listitem1=new ListItem(strtemp,strtemp);
thematic.Items.Add(listitem1);
}
OleDr.Read();
OleConn.Close();
newstime.Text=DateTime.Now.ToString();
}
strtemp=OleDr[2].tostring();//此处要用该列的索引位置
listitem1=new ListItem(strtemp,strtemp);
thematic.Items.Add(listitem1);
}
//OleDr.Read();
OleDr.GetString(2); -》 OleDr.GetString[2];
// vb.net可以这么用 但要将;去掉
----------------------------------------------------
楼主,这个问题 你应该先自己调试一下 ,这样自己能知道问题出在那,再找找相应的资料
这样你的水平会提高很快的而且现在大部分人用.net开发 都是代码和页面分离的 建议你换一本书看看 (有些跑题 ,见谅)。