Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Errore lettura database

    Ciao,
    ho preparato e testato un po' di pagine su un sito aruba con servizio mysql, e fin qui tutto ok. Adesso devo spostare le pagine su un sito sempre aruba ma con server dedicato e sempre database sql.

    Quel che succede è che non mi legge il database ma non mi da neanche errore nella stringa di connessione che risulta essere la seguente:

    codice:
    ConnectionString = "Provider=sqloledb; Data Source=XX.XXX.XXX.XX; Initial Catalog=XXXXXXXXX; User Id=XXXXXXXXX; Password=XXXXXXXX;" 
    Set Connection = Server.CreateObject("ADODB.Connection")
    Connection.Open ConnectionString 
    
    'e la query
    sql_utenti = "SELECT * FROM Utenti WHERE id = " & CInt(scompatta(1)) 
    
    Set rs_utenti = Server.CreateObject("ADODB.Recordset")
    rs_utenti.Open sql_utenti, Connection ,3,3
    praticamente se leggo il database mi da eof quando invece sono presenti i dati corrispondeti. Potrebbe essere un problema di connessione al database?
    Vi è mai successo? Mentre scrivo mi è venuto un dubbio.. potrebbero essere le librerie ADO non installate sul server?

    Grazie

    Ciao
    Fabio

  2. #2
    ----------------------------------------------------
    impariamo a fare un po' di debug

    *subito* dopo la composizione della stringa SQL metti

    Response.Write "maGGica SQL...: " & sql_utenti
    Response.Flush

    poi posta quello che viene a video
    ----------------------------------------------------

  3. #3
    optime come sospettavo il problema sta a monte della sql...

    ho preparato un file di test per la connessione..

    codice:
    <%
    CID = request("id_conn")
    
    
    if CID = 1 then
    ConnectionString = "Provider=sqloledb;Data Source=00.000.000.00;Initial Catalog=odp;User Id=utente;Password=pass;" 
    end if
    if CID = 2 then
    ConnectionString="Server=localhost\SqlExpress;Database=odp;User=utente;Pwd=pass;"
    end if
    if CID = 3 then
    ConnectionString="Server=00.000.000.00;Database=odp;User=utente;Pwd=pass;"
    end if
    if CID = 4 then
    ConnectionString = "Provider=sqloledb; Data Source=localhost\SqlExpress; Initial Catalog=odp; User Id=utente; Password=pass;" 
    end if
    if CID = 5 then
    ConnectionString="Provider=sqloledb;Data Source=localhost\SqlExpress;Initial Catalog=odp;User Id=utente;Password=pass;"
    end if
    if CID = 6 then
    ConnectionString="Provider=sqloledb;Data Source=127.0.0.1;Initial Catalog=odp;User Id=utente;Password=pass;"
    end if
    if CID = 7 then
    ConnectionString="Server=localhost\SqlExpress;Database=odp;User=utente;Pwd=pass;"
    end if
    if CID = 8 then
    ConnectionString="Provider=MySqlProv;Data Source=""server=00.000.000.00;DB=odp;User=utente;Password=pass;Port=3306;"""
    end if
    if CID = 9 then
    ConnectionString="Provider=MySqlProv;Data Source=00.000.000.00;DB=odp;User=utente;Password=pass;Port=3306;"
    end if
    if CID = 10 then
    ConnectionString="Provider=MySqlProv;""Data Source=Server=localhost\SqlExpress;DB=odp;User=utente;Password=pass;Port=3306;"""
    end if
    if CID = 11 then
    ConnectionString="Provider=MySqlProv;""Data Source=localhost\SqlExpress;DB=odp;User=utente;Password=pass;Port=3306;"""
    end if
    if CID = 13 then
    ConnectionString="Provider=MySqlProv;""Data Source=Server=localhost\SqlExpress;DB=odp;User=utente;Password=pass;Port=3306;"""
    end if
    if CID = 14 then
    ConnectionString="Provider=MySqlProv;Data Source=Server=localhost\SqlExpress;DB=odp;User=utente;Password=pass;Port=3306;"
    end if
    if CID = 15 then
    ConnectionString="Provider=MySqlProv;Data Source=localhost\SqlExpress;DB=odp;User=utente;Password=pass;Port=3306;"
    end if
    if CID = 16 then
    ConnectionString="Provider=MySqlProv;Data Source=Server=localhost;DB=odp;User=utente;Password=pass;Port=3306;"
    end if
    if CID = 17 then
    ConnectionString="Driver={MySQL};Database=odp;UID=utente;PWD=pass;" 
    end if
    if CID = 18 then
    ConnectionString="Driver={MySQL};Server=localhost\SqlExpress;Database=odp;UID=utente;PWD=pass;" 
    end if
    if CID = 19 then
    ConnectionString="Driver={MySQL};Data Source=localhost\SqlExpress;Database=odp;UID=utente;PWD=pass;" 
    end if
    if CID = 20 then
    ConnectionString="Driver={MySQL};Server=localhost;Database=odp;UID=utente;PWD=pass;" 
    end if
    
    Set Connection = Server.CreateObject("ADODB.Connection")
    Connection.Open ConnectionString
    
    sql_utenti = "SELECT * FROM Utenti WHERE id = 1"  
    
    Set rs_utenti = Server.CreateObject("ADODB.Recordset")
    rs_utenti.Open sql_utenti, Connection ,3,3
    
    for z = 0 to 7
    response.write "
    " & rs_utenti(z)
    next
    
    %>
    e nessuna delle connessioni è andata a buonfine..

    con la connessione 1 ottengo:

    Microsoft OLE DB Provider for SQL Server error '80004005'

    [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.

    /test_connessione.asp, line 64

    con la connessione 2 ottengo:
    Microsoft OLE DB Provider for ODBC Drivers error '80004005'

    [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

    /test_connessione.asp, line 64

    con la connessione 3 ottengo:
    Microsoft OLE DB Provider for ODBC Drivers error '80004005'

    [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

    /test_connessione.asp, line 64

    con la connessione 4 ottengo:
    Microsoft OLE DB Provider for SQL Server error '80004005'

    [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.

    /test_connessione.asp, line 64

    e bene o male poi si ripetono...
    non capisco come mai su un sito funziona e sull'altro no...

    che caspita può esserci di diverso nei 2 database?
    la connessione 1 è funzionante sull'altro sito ma non qui...

    Idee?
    Grazie
    Ciao

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.