Ciao a tutti,

sto utilizzando VS2008 e devo connettermi ed estrarre dei dati da un db di DB2.
Ho provato ad utilizzare due strade:
1)connessione attraverso Odbc
2)connessione utilizzando la libreria IBM.data.Db2.dll ed estrazione dati.

Caso 1: Eseguendo questo codice non riesco ad aprire la connessione al db.

codice:
Public Sub ConnessioneDB()
        Dim db_connessione As New OdbcConnection()
        Dim connect As Boolean
        Dim string_connection As String

        connect = False
        lblMessage.Visible = False

        'connessione al db.
        string_connection   
                     "Server=server_name;DSN=name;UID=xxxx;PWD=yyyyy;"

        Try
            db_connessione.ConnectionString = string_connection
            db_connessione.Open()
            connect = True
            lblMessage.Visible = True
            lblMessage.Text = My.Resources.ResourceMessage.SuccessOperation
            db_connessione.Close()
        Catch
            connect = False
            btnEntra.Visible = False
            lblMessage.Visible = True
            lblMessage.Text = My.Resources.ResourceMessage.NegatedOperation
        End Try
    End Sub
Caso 2: Eseguendo questo codice riesco a fare la connessione al db ma non riesco ad estrarre nulla.

p.s. dgrRubrica è una datagridview

Connessione:
codice:
Public Sub ConnessioneDB()
        Dim connect As Boolean
        Dim string_connection As String
        Dim db2_connessione As New DB2Connection()
        connect = False
        lblMessage.Visible = False

        'connessione al db.
        string_connection = "Server=server_name;Database=name;UID=xxxx;PWD=yyyy;"
        db2_connessione.ConnectionString = string_connection

        Try
            db2_connessione.Open()
            connect = True
            lblMessage.Visible = True
            lblMessage.Text = My.Resources.ResourceMessage.SuccessOperation
            db2_connessione.Close()
        Catch
            connect = False
            btnEntra.Visible = False
            lblMessage.Visible = True
            lblMessage.Text = My.Resources.ResourceMessage.NegatedOperation
        End Try
    End Sub

Estrazione dati:

codice:
Private Sub btnEstrai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEstrai.Click
        Dim query_string As String = "Select * From USER_LIST"
        Dim ds As DataSet = New DataSet()
        Dim db2_connessione As New DB2Connection()
        Dim string_connection As String
                                     = "Server=server_name;Database=name;UID=xxxx;PWD=yyyy;"
        db2_connessione.ConnectionString = string_connection
        Dim cmd As DB2Command = New DB2Command(query_string, db2_connessione)
        Dim cmdd As DB2DataAdapter = New DB2DataAdapter()
        db2_connessione.Open()
        cmdd.SelectCommand = cmd
        cmdd.Fill(ds)
        db2_connessione.Close()
        dgrRubrica.DataSource = ds
End Sub
Grazie

Rick