0

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 :(

2
Contributors
2
Replies
10
Views
2 Years
Discussion Span
Last Post by cgeier
0

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"
0

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 by cgeier

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.