Wrox Programmer Forums
|
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 8th, 2006, 01:58 PM
Authorized User
 
Join Date: May 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to jd_erd Send a message via AIM to jd_erd Send a message via MSN to jd_erd Send a message via Yahoo to jd_erd
Default ASP.NET PROGRAM PROBLEM

 SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.

Source Error:

Line 17: sqladapt.SelectCommand = sqlcom
Line 18: dsdata.Clear()
Line 19: sqladapt.Fill(dsdata, "data")
Line 20: End Sub
Line 21:


Source File: \\Coreabil\coreabil\coresql.vb Line: 19

Stack Trace:

[SqlException: SQL Server does not exist or access denied.]
   System.Data.SqlClient.ConnectionPool.GetConnection (Boolean& isInTransaction) +472
   System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
   System.Data.SqlClient.SqlConnection.Open() +384
   System.Data.Common.DbDataAdapter.QuietOpen(IDbConn ection connection, ConnectionState& originalState) +44
   System.Data.Common.DbDataAdapter.FillFromCommand(O bject data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +36
   coreabil.coresql.getdata(Object strquery) in \\Coreabil\coreabil\coresql.vb:19
   coreabil.studentform.Page_Load(Object sender, EventArgs e) in \\Coreabil\coreabil\studentform.aspx.vb:83
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +731


Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

WebConfig File

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.web>

    <!-- DYNAMIC DEBUG COMPILATION
          Set compilation debug="true" to insert debugging symbols (.pdb information)
          into the compiled page. Because this creates a larger file that executes
          more slowly, you should set this value to true only when debugging and to
          false at all other times. For more information, refer to the documentation about
          debugging ASP.NET files.
    -->
    <compilation defaultLanguage="vb" debug="true" />

    <!-- CUSTOM ERROR MESSAGES
          Set customErrors mode="On" or "RemoteOnly" to enable custom error messages, "Off" to disable.
          Add <error> tags for each of the errors you want to handle.
    -->
    <customErrors mode="Off"/>

    <!-- AUTHENTICATION
          This section sets the authentication policies of the application. Possible modes are "Windows",
          "Forms", "Passport" and "None"
    -->
    <authentication mode="Windows" />


    <!-- AUTHORIZATION
          This section sets the authorization policies of the application. You can allow or deny access
          to application resources by user or role. Wildcards: "*" mean everyone, "?" means anonymous
          (unauthenticated) users.
    -->
    <authorization>
        <allow users="*" />

            <!-- <allow users="[comma separated list of users]"
                             roles="[comma separated list of roles]"/>
                  <deny users="[comma separated list of users]"
                             roles="[comma separated list of roles]"/>
            -->
    </authorization>

    <!-- APPLICATION-LEVEL TRACE LOGGING
          Application-level tracing enables trace log output for every page within an application.
          Set trace enabled="true" to enable application trace logging. If pageOutput="true", the
          trace information will be displayed at the bottom of each page. Otherwise, you can view the
          application trace log by browsing the "trace.axd" page from your web application
          root.
    -->
    <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />


    <!-- SESSION STATE SETTINGS
          By default ASP.NET uses cookies to identify which requests belong to a particular session.
          If cookies are not available, a session can be tracked by adding a session identifier to the URL.
          To disable cookies, set sessionState cookieless="true".
    -->
    <sessionState
            mode="InProc"
            stateConnectionString="tcpip=127.0.0.1:42424"
            sqlConnectionString="data source=127.0.0.1;user id=sa;password="
            cookieless="false"
            timeout="20"
    />

    <!-- GLOBALIZATION
          This section sets the globalization settings of the application.
    -->
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" />


  </system.web>

</configuration>


CoreSQL File

Module coresql
    'Dataset dsdata is used to pass data to forms from the database
    Public dsdata As New DataSet
    Dim strquery As String
    Public strresult As String


    'getdata gets data from the database
    'getdata(query string)
    Public Sub getdata(ByVal strquery)
        Dim sqlconn As New SqlClient.SqlConnection
        Dim sqlcom As New SqlClient.SqlCommand
        Dim sqladapt As New SqlClient.SqlDataAdapter
        sqlconn.ConnectionString = "User ID=" & config.strdbuser & ";Initial Catalog=" & config.strdbname & ";Data Source=" & config.strdbip & ";Password=" & config.strdbpass
        sqlcom.Connection = sqlconn
        sqlcom.CommandText = strquery
        sqladapt.SelectCommand = sqlcom
        dsdata.Clear()
        sqladapt.Fill(dsdata, "data")
    End Sub

    'updatedata updates the database or deletes records
    'updatedata(query string)
    Public Sub updatedata(ByVal strquery)
        Dim sqlconn As New SqlClient.SqlConnection
        Dim sqlcom As New SqlClient.SqlCommand
        strresult = ""
        sqlconn.ConnectionString = "User ID=" & config.strdbuser & ";Initial Catalog=" & config.strdbname & ";Data Source=" & config.strdbip & ";Password=" & config.strdbpass
        sqlcom.Connection = sqlconn
        sqlcom.CommandText = strquery
        sqlcom.Connection.Open()
        Try
            sqlcom.ExecuteNonQuery()
            strresult += "Good"
        Catch
            strresult += ";Failed" & Err.Description & ";"
        End Try
        sqlcom.Connection.Close()
    End Sub
End Module

Config File

Module config
    'Coreabilities Web Self Assessment Configuration File
    'All options should be put in quotes

    'Section 1: Database Access
    'These are the database settings
    'Database Server IP or NetBIOS Name
    Public strdbip As String = "localhost"
    'Database Server Initial Database Name
    Public strdbname As String = "coreabil"
    'Database Server Username
    Public strdbuser As String = "coreabil"
    'Database Server Password
    Public strdbpass As String = "sorry"

    'Section 2: Administrator Access
    'Administrator Password
    Public stradminpass As String = "sorry"

End Module







jd erd
__________________
jd erd
 
Old May 9th, 2006, 10:44 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Hi,

Its seems for some reason that your connection string is not getting passed correctly or is incorrect.

Plus, the way you are connecting seems very complicated to me.

I'm sure there are many ways of doing it but this one works well for me.

In the webconfig file:

<appSettings>
<add key="dbcAnyName" value="Server=[Server Name];DATABASE=[Database Name];UID=appuser;PWD=[appuser password];" />
</appSettings>

To access this connection in the code behind:

_oConn = New SqlConnection(ConfigurationSettings.AppSettings("d bcAnyName"))
_oConn.Open()

Dim SQL as String = "SELECT blah, blah, blah;"
Dim CMD As SqlCommand
Dim oRS As SqlDataReader
CMD = New SqlCommand
CMD.Connection = _oConn
CMD.CommandText = SQL
oRS = CMD.ExecuteReader()

oRS.Close()
_oConn.Close()

Hope this helps.

Richard









Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom HTTP 404 Problem w/ASP to ASP.NET kwilliams ASP.NET 2.0 Professional 7 November 26th, 2007 04:17 PM
ASP.NET program Error jd_erd BOOK: ASP.NET Website Programming Problem-Design-Solution 1 May 8th, 2006 10:25 PM
Problem with Exercise in Beg. asp.net for VB.net! mrfella71 BOOK: Beginning ASP.NET 1.0 1 October 23rd, 2005 12:06 PM
ASP.NET E-Commerce Program Problem-Design-Solution ruimeisoft All Other Wrox Books 6 August 17th, 2004 03:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.