×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
Lee, take a look at the "IBM DB2 UDB for iSeries .NET Provider Technical
Reference". There are many samples of how to use the classes. I would
also recommend getting paper copies of ISBN 0738490555 and ISBN
0738496561.
Create a new class file in your project.
Paste this code in there:
Imports IBM.Data.DB2.iSeries
Imports System.Data
Public Class DB2ADO
Private _cn_connString As String = ""
Private _cn As iDB2Connection
Private _cn_iSeriesFQDN As String = "myIseries.domain.com"
Private _cn_initialCatalog As String = "*SYSBAS" ' "s10913ce"
Private _cn_connTimeout As String = "20"
Private _cn_user As String = ""
Private _cn_pass As String = ""
Private _cn_SSL As String = "FALSE"
Private _cn_Naming As String = "SQL" ' "System"
Private _cn_LibraryList = "*USRLIBL"
Private _cn_DataCompression = "TRUE"
Private _cn_HexParser = "Character" ' Not needed
Private _ConvertByte As Boolean = False
'Private _cn_defaultCollection As String = "AMFLIB"
' Trace Facility
Private _trace_bin As String = "C:\program files\ibm\Client
Access\cwbmptrc.exe"
Private _trace_out As String = "C:\program files\ibm\Client
Access\idb2trace.txt"
Public Sub New(ByVal iSeriesFQDN As String, ByVal user As String,
ByVal pass As String, Optional ByVal ConvertByte As Boolean = True)
_cn_iSeriesFQDN = iSeriesFQDN
_cn_user = user
_cn_pass = pass
_ConvertByte = ConvertByte
Public Function Connect() As Boolean
_cn = New iDB2Connection
_cn.ConnectionString = _cn_connString
Dim failFlag As Boolean = True
Try
_cn.Open()
Console.WriteLine("Server Version: " & _cn.ServerVersion)
Console.WriteLine("Default Collection: " &
_cn.DefaultCollection)
Console.WriteLine("Job: " & _cn.JobName)
Catch ex As Exception
failFlag = False
End Try
Return failFlag
End Function
Public Sub Disconnect()
_cn.Close()
End Sub
Public Function Query(ByVal SelectCommand As String) As DataTable
If _cn.State = ConnectionState.Open Then
If _ConvertByte Then
iDB2ProviderSettings.CharBitDataAsString = True ' TODO:
thank you
iDB2ProviderSettings.CharBitDataCcsid = 37
Else
iDB2ProviderSettings.CharBitDataAsString = False
End If
Dim cmd As New iDB2Command(SelectCommand, _cn)
Dim da As New iDB2DataAdapter(cmd)
Dim ds As New DataSet
Try
da.Fill(ds, "table0")
If ds.Tables("table0").Rows.Count = 0 Then
Return New DataTable
ElseIf ds.Tables("table0").Rows.Count > 0 Then
Return ds.Tables("table0")
End If
Catch ex As Exception
Console.WriteLine(ex.Message)
Return New DataTable
End Try
Else
Return New DataTable
End If
End Function
End Class
Then in your _default class you can do this:
Dim myProvider as new DB2ADO("yourISeries.yourDomain.Com", "user",
"pass")
If myProvider.Connect Then
Dim dt as System.Data.DataTable = myProvider.Query("select *
from customerTable")
myProvider.Disconnect()
End If
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.