Function getnewss(ByVal id As String) As OleDbDataReader
        Dim dr As OleDbDataReader
        
        Dim conn As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=j:\fsxx\data\fsxx.mdb")
        conn.Open()
        Dim cmd As New OleDbCommand("select * from news_content where id=" & id, conn)
        dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)        If conn.State = ConnectionState.Connecting Then
            conn.Close()
        End If        Return dr
    End Function
数据库存在,并且有数据.但是运行时缺出问题,提示:不存在此行/列的数据。改成用datatable就好使了.代码如下:
 Function getanews(ByVal id As String) As DataTable
        Dim dt As New DataTable
        Dim ds As New DataSet
        Dim conn As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=j:\fsxx\data\fsxx.mdb")
        conn.Open()        Dim dataadap As New OleDbDataAdapter("select * from news_content where id=" & id, conn)
        dataadap.Fill(ds, "news")
        dt = ds.Tables("news")
        If conn.State = ConnectionState.Connecting Then
            conn.Close()
        End If        Return dt
    End Function请问是怎么回事?

解决方案 »

  1.   


    Dim conn As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=j:\fsxx\data\fsxx.mdb")
    改成:
    Dim conn As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=j"&
    server.mappath("data\fsxx.mdb"))
    为什么就不好使呢
      

  2.   


    Dim conn As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=j:\fsxx\data\fsxx.mdb")
    改成:
    Dim conn As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=j"&
    server.mappath("data\fsxx.mdb"))
    为什么就不好使呢
    ------------------Dim conn As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" &
    server.mappath("data\fsxx.mdb"))
    为什么就不好使呢
      

  3.   

    你的代码是写在.vb文件里面的吗?

    imports system.web
    imports system.web.ui
    public class myclass
    inherits page
    .....
      

  4.   

    写上这些还是提示server没有定义.不好使
      

  5.   

    你是在模块还是类里面用的这个东西
    建议使用:System.Web.HttpContext.Current.Request.PhysicalApplicationPath()
    这个函数来取路径。