Hi!

Could you help me initialize or load the data into a Data Grid View Control using iDB2 Connection? I've tried this code I've seen from the net but it does not seem to work :(

I am initializing the connection using form_load and not in the Properties Window.

Imports IBM.Data.DB2
Imports IBM.Data.DB2.iSeries

Dim cmdGet As New iDB2Command
Dim daGet As New iDB2DataAdapter
Dim dsGet As New DataSet

Dim sqlGet As String

conn.ConnectionString = str
conn.Open()

'****Display all the records in dgTranslog
sqlGet = "SELECT * FROM exptranslog"

cmdGet.CommandText = sqlGet
cmdGet.Connection = conn

daGet.SelectCommand = cmdGet

daGet.Fill(dsGet)
dgTranslog.DataSource = dsGet

I know there is something wrong/missing in this code. I just don't know what it is :(

Alraedy working!

Fix:

'****Display all the records in dgTranslog
sqlGet = "SELECT * FROM exptranslog"

cmdGet.CommandText = sqlGet
cmdGet.Connection = conn

daGet.SelectCommand = cmdGet

daGet.Fill(dsGet, "expTranslog")
dgTranslog.DataSource = dsGet
dgTranslog.DataMember = "expTranslog"

Use the code from your other post that uses the DataTable. Set the DataTable as the datasource for the DataGridView. A DataSet can hold multiple data tables.

Edited 2 Years Ago by cgeier

This question has already been answered. Start a new discussion instead.