Problem Getting Data From DataSet

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nathan Sokalski

    Problem Getting Data From DataSet

    I have retrieved data from a database using a SELECT statement that includes
    an INNER JOIN. The data seems to be retrieved to the DataSet OK, but I am
    having trouble getting the data from the DataSet. The code I am using is as
    follows:


    Private Sub btnDownloadDB_C lick(ByVal sender As System.Object, ByVal e As
    System.Web.UI.I mageClickEventA rgs) Handles btnDownloadDB.C lick
    Dim papdatabase As New DataSet
    Dim cmdSelect As New System.Data.Ole Db.OleDbCommand ("SELECT
    members.organiz ation,membernam es.fname,member names.lname,mem bers.address1,m embers.address2 ,members.city,m embers.state,me mbers.zip,membe rs.phone,member s.email,members .fax,members.we bsite
    FROM members INNER JOIN membernames ON
    members.memberi d=membernames.m emberid", New
    OleDb.OleDbConn ection("PROVIDE R=Microsoft.Jet .OLEDB.4.0;DATA SOURCE=" &
    Server.MapPath( "/papresenters.md b")))
    Dim dataadapterSele ct As New System.Data.Ole Db.OleDbDataAda pter
    dataadapterSele ct.SelectComman d = cmdSelect
    dataadapterSele ct.Fill(papdata base)

    Response.ClearC ontent()
    Response.Conten tType = "text/plain"
    Response.AddHea der("content-disposition",
    "attachment;fil ename=members.t xt")
    Const TAB As String = Chr(9)
    Response.Write( "ORGANIZATI ON" & TAB & "FNAME LNAME" & TAB & "ADDRESS1" &
    TAB & "ADDRESS2" & TAB & "CITY" & TAB & "STATE" & TAB & "ZIP" & TAB &
    "PHONE" & TAB & "EMAIL" & TAB & "FAX" & TAB & "WEBSITE")
    For Each member As System.Data.Dat aRow In papdatabase.Tab les(0).Rows
    Response.Write( ControlChars.Ne wLine & CStr(member("or ganization")) &
    TAB & CStr(member("fn ame")) & " " & CStr(member("ln ame")) & TAB &
    CStr(member("ad dress1")) & TAB & CStr(member("ad dress2")) & TAB &
    CStr(member("ci ty")) & TAB & CStr(member("st ate")) & TAB &
    CStr(member("zi p")) & TAB & CStr(member("ph one")) & TAB &
    CStr(member("em ail")) & TAB & CStr(member("fa x")) & TAB &
    CStr(member("we bsite")))
    Next
    Response.End()
    End Sub


    This gives me the following error:
    Server Error in '/' Application.
    --------------------------------------------------------------------------------

    Runtime Error
    Description: An application error occurred on the server. The current custom
    error settings for this application prevent the details of the application
    error from being viewed remotely (for security reasons). It could, however,
    be viewed by browsers running on the local server machine.

    Details: To enable the details of this specific error message to be viewable
    on remote machines, please create a <customErrors > tag within a "web.config "
    configuration file located in the root directory of the current web
    application. This <customErrors > tag should then have its "mode" attribute
    set to "Off".

    <!-- Web.Config Configuration File -->

    <configuratio n>
    <system.web>
    <customErrors mode="Off"/>
    </system.web>
    </configuration>

    Notes: The current error page you are seeing can be replaced by a custom
    error page by modifying the "defaultRedirec t" attribute of the application's
    <customErrors > configuration tag to point to a custom error page URL.

    <!-- Web.Config Configuration File -->

    <configuratio n>
    <system.web>
    <customErrors mode="RemoteOnl y" defaultRedirect ="mycustompage. htm"/>
    </system.web>
    </configuration>

    Based on the tests I managed to do, the problem seems to be in the For Each
    loop near the end, when I comment out this loop everything goes fine. What
    am I doing wrong? Thanks.
    --
    Nathan Sokalski
    njsokalski@hotm ail.com
    有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。



  • Ben Strackany

    #2
    Re: Problem Getting Data From DataSet

    You should enable debugging on that page (or set debug mode to RemoteOnly,
    log into the box, & hit the page). That will show you the exact line & error
    string, which should quickly show you exactly what the issue is.

    --
    Benjamin Strackany
    DevelopmentNow is an award-winning creative software development agency integrating mobile, web, hardware, mixed reality, and emerging technology.



    "Nathan Sokalski" <njsokalski@hot mail.com> wrote in message
    news:OA3ywf3oFH A.2792@TK2MSFTN GP10.phx.gbl...[color=blue]
    > I have retrieved data from a database using a SELECT statement that[/color]
    includes[color=blue]
    > an INNER JOIN. The data seems to be retrieved to the DataSet OK, but I am
    > having trouble getting the data from the DataSet. The code I am using is[/color]
    as[color=blue]
    > follows:
    >
    >
    > Private Sub btnDownloadDB_C lick(ByVal sender As System.Object, ByVal e As
    > System.Web.UI.I mageClickEventA rgs) Handles btnDownloadDB.C lick
    > Dim papdatabase As New DataSet
    > Dim cmdSelect As New System.Data.Ole Db.OleDbCommand ("SELECT
    >[/color]
    members.organiz ation,membernam es.fname,member names.lname,mem bers.address1,m e
    mbers.address2, members.city,me mbers.state,mem bers.zip,member s.phone,members .
    email,members.f ax,members.webs ite[color=blue]
    > FROM members INNER JOIN membernames ON
    > members.memberi d=membernames.m emberid", New
    > OleDb.OleDbConn ection("PROVIDE R=Microsoft.Jet .OLEDB.4.0;DATA SOURCE=" &
    > Server.MapPath( "/papresenters.md b")))
    > Dim dataadapterSele ct As New System.Data.Ole Db.OleDbDataAda pter
    > dataadapterSele ct.SelectComman d = cmdSelect
    > dataadapterSele ct.Fill(papdata base)
    >
    > Response.ClearC ontent()
    > Response.Conten tType = "text/plain"
    > Response.AddHea der("content-disposition",
    > "attachment;fil ename=members.t xt")
    > Const TAB As String = Chr(9)
    > Response.Write( "ORGANIZATI ON" & TAB & "FNAME LNAME" & TAB & "ADDRESS1"[/color]
    &[color=blue]
    > TAB & "ADDRESS2" & TAB & "CITY" & TAB & "STATE" & TAB & "ZIP" & TAB &
    > "PHONE" & TAB & "EMAIL" & TAB & "FAX" & TAB & "WEBSITE")
    > For Each member As System.Data.Dat aRow In papdatabase.Tab les(0).Rows
    > Response.Write( ControlChars.Ne wLine & CStr(member("or ganization"))[/color]
    &[color=blue]
    > TAB & CStr(member("fn ame")) & " " & CStr(member("ln ame")) & TAB &
    > CStr(member("ad dress1")) & TAB & CStr(member("ad dress2")) & TAB &
    > CStr(member("ci ty")) & TAB & CStr(member("st ate")) & TAB &
    > CStr(member("zi p")) & TAB & CStr(member("ph one")) & TAB &
    > CStr(member("em ail")) & TAB & CStr(member("fa x")) & TAB &
    > CStr(member("we bsite")))
    > Next
    > Response.End()
    > End Sub
    >
    >
    > This gives me the following error:
    > Server Error in '/' Application.
    > --------------------------------------------------------------------------[/color]
    ------[color=blue]
    >
    > Runtime Error
    > Description: An application error occurred on the server. The current[/color]
    custom[color=blue]
    > error settings for this application prevent the details of the application
    > error from being viewed remotely (for security reasons). It could,[/color]
    however,[color=blue]
    > be viewed by browsers running on the local server machine.
    >
    > Details: To enable the details of this specific error message to be[/color]
    viewable[color=blue]
    > on remote machines, please create a <customErrors > tag within a[/color]
    "web.config "[color=blue]
    > configuration file located in the root directory of the current web
    > application. This <customErrors > tag should then have its "mode" attribute
    > set to "Off".
    >
    > <!-- Web.Config Configuration File -->
    >
    > <configuratio n>
    > <system.web>
    > <customErrors mode="Off"/>
    > </system.web>
    > </configuration>
    >
    > Notes: The current error page you are seeing can be replaced by a custom
    > error page by modifying the "defaultRedirec t" attribute of the[/color]
    application's[color=blue]
    > <customErrors > configuration tag to point to a custom error page URL.
    >
    > <!-- Web.Config Configuration File -->
    >
    > <configuratio n>
    > <system.web>
    > <customErrors mode="RemoteOnl y"[/color]
    defaultRedirect ="mycustompage. htm"/>[color=blue]
    > </system.web>
    > </configuration>
    >
    > Based on the tests I managed to do, the problem seems to be in the For[/color]
    Each[color=blue]
    > loop near the end, when I comment out this loop everything goes fine. What
    > am I doing wrong? Thanks.
    > --
    > Nathan Sokalski
    > njsokalski@hotm ail.com
    > http://www.nathansokalski.com/
    >
    >[/color]


    Comment

    Working...