By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,650 Members | 1,785 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,650 IT Pros & Developers. It's quick & easy.

Problem Getting Data From DataSet

P: n/a
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.c ity,members.state,members.zip,members.phone,member s.email,members.fax,members.website
FROM members INNER JOIN membernames ON
members.memberid=membernames.memberid", New
OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLED B.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.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
http://www.developmentnow.com
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:OA**************@TK2MSFTNGP10.phx.gbl...
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,me
mbers.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.OLED B.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.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.