I'm trying to connect to a AS400 server using ODBC driver via vb.net application but the problem is that I am trying to fill a dataset and whenever I want to display the data I don't find any thing
This is my code:
Dim cn As OdbcConnection
Dim cm As OdbcCommand
Dim dm As OdbcDataAdapter
Sub ConnServer()
Try
cn = New OdbcConnection("DSN=AS400_CA;UID=root;PWD=*****;")
cn.Open()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Ecriture Comptable")
End Try
End Sub
Public Function GetData(query As String) As DataTable
Try
cn = New OdbcConnection("DSN=AS400_CA;UID=root;PWD=*****;")
Dim cmd As OdbcCommand = New OdbcCommand(query, cn)
cn.Open()
Dim ds = New DataSet()
cmd.Connection = cn
dm.SelectCommand = cmd
dm.Fill(ds, "table")
Dim data = ds.Tables("table")
cn.Close()
Return data
Catch ex As Exception
con.Close()
Return New DataTable()
End Try
End Function
```