经检测,就是这个程序段出了问题,请各位指点: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();
}

解决方案 »

  1.   

    while(OleDr.Read()){
    strtemp=OleDr[2].tostring();//此处要用该列的索引位置
    listitem1=new ListItem(strtemp,strtemp);
    thematic.Items.Add(listitem1);
    }
    //OleDr.Read();
      

  2.   

    while循环后 这一句 OleDr.Read(); 是什么意思 ?还能再read吗?
    OleDr.GetString(2); -》 OleDr.GetString[2];
    // vb.net可以这么用 但要将;去掉
      

  3.   

    在调试模式下 将 strConn 的值取出来看看,是否正确
    ----------------------------------------------------
    楼主,这个问题 你应该先自己调试一下 ,这样自己能知道问题出在那,再找找相应的资料
    这样你的水平会提高很快的而且现在大部分人用.net开发 都是代码和页面分离的 建议你换一本书看看  (有些跑题 ,见谅)。