Visualizzazione dei risultati da 1 a 7 su 7
  1. #1
    Utente di HTML.it L'avatar di xamax
    Registrato dal
    Oct 2001
    Messaggi
    141

    Con Asp.Net non si connette

    Salve a tutti, spero che qualcuno mi possa dare una mano...
    il problema è il seguente. Sto riscrivendo in ASP.Net una pagina ASP che mi connetteva ad un db AS400 (che supporta OLe DB) ma pur impazzendonon arrivo a capo di nulla...Per far meglio comprendere posto entrambi i codici:

    Vecchio ma funzionante ASP
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx

    <%
    Dim AS400Connessione
    Dim AS400Command
    Dim AS400File_rs
    Dim ConnectionString
    Dim CommandText
    Dim CommandType
    On Error Resume Next
    '----- dichiarazione di connessione ---------
    ConnectionString = "Provider=IBMDA400;Data Source=192.168.0.51;"
    CommandText = "SELECT * FROM YFILEURO.ARTIC00F "
    CommandType = adCmdText
    '------ apertura connessione --------------
    Set AS400Connection = Server.CreateObject("ADODB.Connection")
    AS400Connection.Open ConnectionString,"USR","PASS"
    Set AS400Command = Server.CreateObject("ADODB.Command")
    AS400Command.ActiveConnection = AS400Connection
    'Comandi da eseguire sul sistema AS/400
    AS400Command.CommandText = CommandText
    AS400Command.CommandType = CommandType
    'Esecuzione comandi
    Set AS400File_rs = AS400Command.Execute

    '************************************************* ************** rs output esempio


    '************************************************* ********** fine output
    If (Err.Number = 0 ) Then
    Else
    '------Errori
    DisplayError AS400Connection, Err.Number, Err.Description, Err.Source, "Main"
    End If
    AS400File_rs.Close
    Set AS400File_rs = Nothing
    Set AS400Command = Nothing
    AS400Connection.Close
    Set AS400Connessione = Nothing
    session.abandon
    %>

    Nuovo ma non funzionante ASPX
    -------------------------------------------------------------------

    <@ Page Language="VB" %>

    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.OleDb" %>

    <html>
    <script runat="server">
    Sub Page_Load(Sender As Object, E As EventArgs)
    Dim objconn As new OleDbConnection _
    ("Provider=IBMDA400;Data Source=192.168.0.51;","","")
    Dim ObjCmd As new OleDbCommand_
    ("Select * From YFILEURO.TA00000F")

    Dim ObjReader as new OleDbReader
    ObjConn.Open ObjConn("WEBUSR","WODSWEB")
    ObjReader=ObJCmd.ExecuteReader

    While ObjReader.Read
    response.write (ObjReader.Getstring(0)&"
    ")
    end While
    ObjConn.close
    end sub
    </script>
    <body>
    </body>
    </html>


    Forse chiedo troppo... ma se avete qualche suggerimento vi ringrazio anticipatamente.
    Ciao a tutti
    -||> xamax <||-

  2. #2
    Utente di HTML.it L'avatar di Umanista
    Registrato dal
    Jan 2002
    Messaggi
    1,022
    Che errore ti restituisce?
    Intanto prova a modificare questa riga

    Dim ObjReader as new OleDbReader

    con

    Dim ObjReader as new OleDbDataReader

  3. #3
    Utente di HTML.it L'avatar di xamax
    Registrato dal
    Oct 2001
    Messaggi
    141
    Ho effettuato la correzione....
    l'errore è questo:
    error
    Messaggio di errore del compilatore: BC30390: "System.Data.OleDb.OleDbDataReader.Private Overloads Sub New(connection As System.Data.OleDb.OleDbConnection, command As System.Data.OleDb.OleDbCommand, depth As Integer, chapter As System.IntPtr)" non è accessibile in questo contesto perché è "Private".
    il codice modificato è:
    Ho comunque un dubbio su dove passare username e password...?
    code
    <@ Page Language="VB" %>

    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.OleDb" %>

    <html>
    <script runat="server">
    Sub Page_Load(Sender As Object, E As EventArgs)
    Dim objconn As new OleDbConnection("Provider=IBMDA400;Data Source=192.168.0.51;")
    Dim objCmd As new OleDbCommand("Select * From YFILEURO.TA00000F")

    Dim objReader as new OleDbDataReader

    objConn.Open ObjConn(,"WEBUSR","WODSWEB")
    objReader=ObJCmd.ExecuteReader

    While objReader.Read
    response.write (ObjReader.Getstring(0)&"
    ")
    end While
    ObjConn.close
    end sub
    </script>
    <body>
    </body>
    </html>

    -||> xamax <||-

  4. #4
    Utente di HTML.it L'avatar di Cartman
    Registrato dal
    Sep 2002
    Messaggi
    246
    Dim objReader as OleDbDataReader
    e non
    Dim objReader as new OleDbDataReader
    C.
    Damose da fa...e volemose bene.
    Carol Woityla 26-2-2004

  5. #5
    Utente di HTML.it L'avatar di Umanista
    Registrato dal
    Jan 2002
    Messaggi
    1,022
    ha ragione Cartman.
    Chiedo scusa per l'errore.

  6. #6
    Utente di HTML.it L'avatar di xamax
    Registrato dal
    Oct 2001
    Messaggi
    141
    Grazie innanzitutto a tutti per suggerimenti.... ma effettivamente il problema più grosso penso sia proprio nella riga sotto:

    ObjConn.Open ObjConn("WEBUSR","WODSWEB")
    'errata
    ObjConn.Open
    'corretta

    ma è che l'AS400 richiede il passaggio della Username e password subito dopo dopo l'apertura della Connessione

    Avete qualche suggerimento ulteriore a parte il suicidio.....

    grazie et ciao
    -||> xamax <||-

  7. #7
    Utente di HTML.it L'avatar di xamax
    Registrato dal
    Oct 2001
    Messaggi
    141

    ORA FUNZIONA

    avevo fatto un po di casino... ora che và mi sembra doveroso postare il codice funzionante, potrebbe essere utile ad altri visto che sui collegamenti all'AS400 non c'è in giro molto.....


    <%@ Page Language="VB" Debug="true" %>
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.OleDb" %>

    <html>
    <script runat="server">
    Sub Page_Load(Sender As Object, E As EventArgs)
    dim objConn as new OleDbConnection("Provider=IBMDA400; Data Source=(indirizzo IP); User ID=USERID; Password=PASSWORD")
    Dim objCmd as new OleDbCommand ("SELECT * FROM LIBRERIA.FILE", objConn)
    Dim objReader as OleDbDataReader
    objConn.open
    objReader= objCmd.ExecuteReader
    While objReader.Read
    Response.Write(objReader.GetString(0)&"
    ")
    end while
    objConn.close
    End sub
    </script>
    <body>ciao</body></html>
    Funziona

    Ancora grazie e ciao a tutti
    -||> xamax <||-

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.