locked
Beginner at ASP.NET - can't figure out why I cannot get program to run with HTML RRS feed

  • Question

  • User-790555925 posted

    I keep receiving the Runtime Error:

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

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

    whenever I try to run  my program, which is intended to access database information using an HTML identifier.

    What I have is below and it is linked to an XML file within Visual Studio. Does anybody have any solution? I cannot figure out what I'm doing wrong!

    Imports System.Data.SqlClient

    Public Class genus
        Inherits System.Web.UI.Page

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            PATreesXML()


        End Sub

        Private Sub P()
            Throw New NotImplementedException()
        End Sub

        Sub PATreesXML()
            Dim choice = Request("genus")
            Dim SQL1 = "SELECT * FROM genus WHERE genusid = '8'"
            If choice = "2" Then
                SQL1 = "SELECT * FROM genus WHERE genusid = '9'"
            End If

            Dim XMLOutput = "<?xml version=""1.0""  encoding=""utf-8"" ?>"
            XMLOutput = XMLOutput + "<?xml-stylesheet type=""text/xsl"" href=""PATrees.xslt""?>"
            XMLOutput = XMLOutput + "<tree"
            XMLOutput = XMLOutput + " xmlns = ""http://www.w3schools.com"""
            XMLOutput = XMLOutput + " xmlns:xsi = ""http://www.w3.org/2001/XMLSchema-instance"""
            XMLOutput = XMLOutput + " xsi:schemaLocation = ""http://www.w3schools.com project.xsd"" >"
            Dim conn As New SqlConnection
            Dim cmd = New SqlCommand(SQL1, conn)
            conn.ConnectionString = ConfigurationManager.ConnectionStrings("dbSQL").ConnectionString
            conn.Open()

            Dim dbreader = cmd.ExecuteReader()
            For Each record In dbreader
                XMLOutput = XMLOutput + "<genus"
                XMLOutput = XMLOutput + " genusid=""" & dbreader.GetInt32(0) & """"
                XMLOutput = XMLOutput + " origin=""" & dbreader.GetString(1) & """"
                XMLOutput = XMLOutput + " >"
                Dim SQL2 = "select spottingdata.treelocation, spottingdata.spotdate, tree.treeid, tree.treename, genus.origin, genus.genusid
    from genus
    join spottingdata
    on genus.genusid = spottingdata.genusid
    join tree
    on tree.treeid = spottingdata.treeid
    WHERE genus.genusid=" & dbreader.GetInt32(0)
                Dim cmd2 = New SqlCommand(SQL2, conn)
                Dim dbreader2 = cmd2.ExecuteReader()
                For Each record2 In dbreader2
                    XMLOutput = XMLOutput + "<spottingdata"
                    XMLOutput = XMLOutput + " spottingid=""" & dbreader2.GetInt32(0) & """"
                    XMLOutput = XMLOutput + " treelocation=""" & dbreader2.GetString(1) & """"
                    XMLOutput = XMLOutput + " spotdate=""" & dbreader2.GetString(2) & """"
                    XMLOutput = XMLOutput + " />"
                Next
                dbreader2.Close()
                XMLOutput = XMLOutput + "</spottingdata>"
            Next
            dbreader.Close()
            cmd.Dispose()
            conn.Close()

            XMLOutput = XMLOutput + "</genus>"
            Response.Write(XMLOutput)

        End Sub

    End Class

    Wednesday, December 14, 2016 5:31 AM

All replies

  • User-821857111 posted

    I keep receiving the Runtime Error:

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

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

    This looks like part of the error message you get when customerrors is set to "on", which hides the actual error. Change customerrors to "off" and then post the actual error message here.

    Wednesday, December 14, 2016 7:19 AM