Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di SPEED78
    Registrato dal
    Jan 2003
    Messaggi
    358

    connessione da webconfig

    ragazzi ma dove sbaglio??? sti impazzendo posto il codice grazie a todos
    codice:
            Dim objConn = ConfigurationManager.ConnectionStrings("connectionstring").ConnectionString
            Dim sql As String = "select * from t_capisaldi"
            Dim objCmd As New OleDbCommand(sql, objConn)
    web config :

    codice:
    <configuration>
        <appSettings/>
        <connectionStrings>
          <add  name="connectionstring" connectionString="Data Source=ROAD-SERVER1;Initial Catalog=ANAS_milano;User ID=admin;Password=ripper"
                providerName="System.Data.SqlClient" />
        </connectionStrings>
    errore
    codice:
    Unable to cast object of type 'System.String' to type 'System.Data.OleDb.OleDbConnection'. 
    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.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Data.OleDb.OleDbConnection'.
    
    Source Error: 
    
    
    Line 117:        Dim objConn = ConfigurationManager.ConnectionStrings("connectionstring").ConnectionString
    Line 118:        Dim sql As String = "select * from t_capisaldi"
    Line 119:        Dim objCmd As New OleDbCommand(sql, objConn)

  2. #2
    Utente di HTML.it L'avatar di Joe Taras
    Registrato dal
    Nov 2003
    residenza
    Taranto
    Messaggi
    955

    Re: connessione da webconfig

    Originariamente inviato da SPEED78
    ragazzi ma dove sbaglio??? sti impazzendo posto il codice grazie a todos
    codice:
            Dim objConn = ConfigurationManager.ConnectionStrings("connectionstring").ConnectionString
            Dim sql As String = "select * from t_capisaldi"
            Dim objCmd As New OleDbCommand(sql, objConn)
    web config :

    codice:
    <configuration>
        <appSettings/>
        <connectionStrings>
          <add  name="connectionstring" connectionString="Data Source=ROAD-SERVER1;Initial Catalog=ANAS_milano;User ID=admin;Password=ripper"
                providerName="System.Data.SqlClient" />
        </connectionStrings>
    errore
    codice:
    Unable to cast object of type 'System.String' to type 'System.Data.OleDb.OleDbConnection'. 
    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.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Data.OleDb.OleDbConnection'.
    
    Source Error: 
    
    
    Line 117:        Dim objConn = ConfigurationManager.ConnectionStrings("connectionstring").ConnectionString
    Line 118:        Dim sql As String = "select * from t_capisaldi"
    Line 119:        Dim objCmd As New OleDbCommand(sql, objConn)
    Ciao questo è il mio Web.Config
    <appSettings>
    <add key="conn" value="Server=(local);Database=zzz;uid=yyy;passwor d=xxx" />
    </appSettings>

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.