Problem Getting Data From DataSet

N

Nathan Sokalski

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_Click(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles btnDownloadDB.Click
Dim papdatabase As New DataSet
Dim cmdSelect As New System.Data.OleDb.OleDbCommand("SELECT
members.organization,membernames.fname,membernames.lname,members.address1,members.address2,members.city,members.state,members.zip,members.phone,members.email,members.fax,members.website
FROM members INNER JOIN membernames ON
members.memberid=membernames.memberid", New
OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &
Server.MapPath("/papresenters.mdb")))
Dim dataadapterSelect As New System.Data.OleDb.OleDbDataAdapter
dataadapterSelect.SelectCommand = cmdSelect
dataadapterSelect.Fill(papdatabase)

Response.ClearContent()
Response.ContentType = "text/plain"
Response.AddHeader("content-disposition",
"attachment;filename=members.txt")
Const TAB As String = Chr(9)
Response.Write("ORGANIZATION" & 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.DataRow In papdatabase.Tables(0).Rows
Response.Write(ControlChars.NewLine & CStr(member("organization")) &
TAB & CStr(member("fname")) & " " & CStr(member("lname")) & TAB &
CStr(member("address1")) & TAB & CStr(member("address2")) & TAB &
CStr(member("city")) & TAB & CStr(member("state")) & TAB &
CStr(member("zip")) & TAB & CStr(member("phone")) & TAB &
CStr(member("email")) & TAB & CStr(member("fax")) & TAB &
CStr(member("website")))
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 -->

<configuration>
<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 "defaultRedirect" attribute of the application's
<customErrors> configuration tag to point to a custom error page URL.

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

<configuration>
<system.web>
<customErrors mode="RemoteOnly" 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.
 
B

Ben Strackany

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,821
Messages
2,569,748
Members
45,726
Latest member
RaleighAll

Latest Threads

Top