Results 1 to 5 of 5

Thread: <<resolved>>Web Services problem with web.config - SQLconnection

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    South Africa
    Posts
    113

    <<resolved>>Web Services problem with web.config - SQLconnection

    Hi,
    I have been trying to follow the football247 demo but am struggling to get the web service to connect to the database.

    Its a sql2000 database that I setup using windowsauthentication - so there is no username and password.

    The db uses stored procedures to read and update data.

    I have a class that is supposed to connect to the database.

    VB Code:
    1. Public Function GetTeams() As TeamData
    2.  
    3.         Dim connection As SqlConnection = New SqlConnection(ConnectionString)
    4.         Try
    5.  
    6.             Dim command As SqlCommand = New SqlCommand("GetTeams", connection)
    7.             command.CommandType = CommandType.StoredProcedure
    8.             Dim adapter As SqlDataAdapter = New SqlDataAdapter(command)
    9.             adapter.TableMappings().Add("Table", "Teams")
    10.             Dim target As TeamData = New TeamData
    11.             adapter.Fill(target)
    12.             Return target
    13.  
    14.         Finally
    15.             If connection.State = ConnectionState.Open Then
    16.                 connection.Close()
    17.  
    18.  
    19.             End If
    20.  
    21.         End Try
    22.  
    23.     End Function



    ConnectionString is a property that reads from the web.config file:
    VB Code:
    1. Public Class TeamDataAccessor
    2.     Public ReadOnly Property ConnectionString() As String
    3.         Get
    4.             Return ConfigurationSettings.AppSettings("ConnectionString")
    5.  
    6.         End Get
    7.     End Property

    The web.config file is:


    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    
    <configuration>
    <appSettings>
    <!--
    Use Integrated security
    -->
    <add
    key="ConnectionString"
    value="Integrated Security=SSPI;database=DataAccessSample.Net;server=localhost" />
    
    </appSettings>
     <identity impersonate="true"
      userName=""  How should I change this so that it will connect to my SQL2000 that is using windows authentication for the login - i.e. no username and no password?
      password=""
      /> 
      
    <system.web>
      
        
        <compilation defaultLanguage="vb" debug="true" />
    
        <customErrors mode="RemoteOnly" />
    
        <!--  AUTHENTICATION 
              This section sets the authentication policies of the application. Possible modes are "Windows", 
              "Forms", "Passport" and "None"
    
              "None" No authentication is performed. 
              "Windows" IIS performs authentication (Basic, Digest, or Integrated Windows) according to 
               its settings for the application. Anonymous access must be disabled in IIS. 
              "Forms" You provide a custom form (Web page) for users to enter their credentials, and then 
               you authenticate them in your application. A user credential token is stored in a cookie.
              "Passport" Authentication is performed via a centralized authentication service provided
               by Microsoft that offers a single logon and core profile services for member sites.
        -->
        <authentication mode="Windows" /> 
    
    
           <authorization>
            <allow users="*" /> <!-- Allow all 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>
    
        <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />
    
    
        <sessionState 
                mode="InProc"
                stateConnectionString="tcpip=127.0.0.1:42424"
    	    sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
                cookieless="false" 
                timeout="20" 
        />
    
        <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
       
      </system.web>
    
    </configuration>
    The error I get when I test the web service is:

    Configuration Error

    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

    Parser Error Message: Unrecognized configuration section 'identity'

    Source Error:


    Line 11:
    Line 12: </appSettings>
    Line 13: <identity impersonate="true"
    Line 14: userName=""
    Line 15: password=""

    If I remove the 'identity' tag then the web service allows me to select which method to invoke. I select the getteams method (the one shown above) and I get the following error:


    System.Data.SqlClient.SqlException: Login failed for user 'IT-WGP2B9HIQFBJ\ASPNET'.
    at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction)
    at System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction)
    at System.Data.SqlClient.SqlConnection.Open()
    at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
    at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
    at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
    at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
    at DataAccessSample.Data.DataAccess.TeamDataAccessor.GetTeams() in C:\Documents and Settings\Steve\My Documents\Visual Studio Projects\DataAccessSample.net\DataAccessSample.Data.DataAccess\TeamDataAccessor.vb:line 21
    at DataAccessSample.Business.Facades.TestFacade.getTeams() in C:\Documents and Settings\Steve\My Documents\Visual Studio Projects\DataAccessSample.net\DataAccessSample.Business.Facades\TestFacade.asmx.vb:line 45

    Thanks in advance
    Last edited by SmagO; Jun 6th, 2005 at 02:02 AM.
    You are living a pacifist dream, and if you dreaming it means you sleeping and you should damn well wake up!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width