Reading records from db2 via iSeries ODBC Driver

I try to connect AS400 DB2 Database via iSeries ODBC Driver and pull data succesfully. When look at DB2, there are 7279 records. But at the lotus, I see only 2312 records. I do not set any filtering. I just say in the code “SELECT * FROM LibraryName.FileName”

The Code is below, could you please tell me what is the wrong? Is there any record amount restriction on Lotus Notes View? I can pull all records from Excel via same ODBC driver successfuly.

Sub Initialize

'Removes old documents.	

Dim session As New NotesSession

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Set db = session.CurrentDatabase

Set collection = db.AllDocuments

Call collection.RemoveAll(True)



'Connecting AS400 and Getting Data

Dim con As New ODBCConnection

Dim qry As ODBCQuery	

Dim result As ODBCResultSet

Dim dsn As String

Dim msg As String

Set con = New ODBCConnection

Set qry = New ODBCQuery

Set result = New ODBCResultSet

Set qry.Connection = con

Set result.Query = qry

con.Userid="UserID"

con.Password="Password"

con.ConnectTo("AS400")

qry.SQL = "SELECT * FROM ADTABRY00.MIFBUR00"

If Not result.Execute Then

	Messagebox result.GetExtendedErrorMessage,, _

	result.GetErrorMessage

	Exit Sub

End If	



Dim doc As NotesDocument

'doc.Form="BolgeUretimRaporu"



Do While Not result.IsEndOfData

	Set doc = New NotesDocument (db)		

	doc.l_BUSRK = result.GetValue("BUSRK")		

	doc.l_BUBRA = result.GetValue("BUBRA")

	

	doc.l_BUBLU = result.GetValue("BUBLU")

	doc.l_BUBLA = result.GetValue("BUBLA")

	doc.l_BUBAD = result.GetValue("BUBAD")

	

	doc.l_BUYIL = result.GetValue("BUYIL")

	doc.l_BUAY = result.GetValue("BUAY")

	

	doc.l_BUDRM = result.GetValue("BUDRM")

	

	doc.l_BUELM = result.GetValue("BUELM")

	doc.l_BUELE = result.GetValue("BUELE")

	doc.l_BUEAS = result.GetValue("BUEAS")

	

	doc.l_BUEYTM = result.GetValue("BUEYTM")

	doc.l_BUEYTE = result.GetValue("BUEYTE")

	doc.l_BUYTAS = result.GetValue("BUYTAS")

	

	doc.l_BUESFM = result.GetValue("BUESFM")

	doc.l_BUESFE = result.GetValue("BUESFE")

	doc.l_BUSFAS = result.GetValue("BUSFAS")

	

	doc.l_BUEMYM = result.GetValue("BUEMYM")

	doc.l_BUEMYE = result.GetValue("BUEMYE")

	doc.l_BUMYAS = result.GetValue("BUMYAS")

	

	doc.l_BUEMDM = result.GetValue("BUEMDM")

	doc.l_BUEMDE = result.GetValue("BUEMDE")

	doc.l_BUMDAS = result.GetValue("BUMDAS")

	

	doc.l_BUGKU = result.GetValue("BUGKU")

	doc.l_BUGKDU = result.GetValue("BUGKDU")

	doc.l_BUGKDA = result.GetValue("BUGKDA")

	doc.l_BUGADI = result.GetValue("BUGADI")

	

	doc.l_BULSTR = result.GetValue("BULSTR")

	doc.l_BUIBTR = result.GetValue("BUIBTR")

	doc.l_BUIATR = result.GetValue("BUIATR")

	

	doc.l_BUIIAD = result.GetValue("BUIIAD")

	doc.l_BUIITU = result.GetValue("BUIITU")

	doc.l_BUDOTU = result.GetValue("BUDOTU")

	doc.l_BUTOTU = result.GetValue("BUTOTU")

	doc.l_BUAOTU = result.GetValue("BUAOTU")

	doc.l_BUHDTU = result.GetValue("BUHDTU")

	doc.l_BUBDTU = result.GetValue("BUBDTU")

	doc.l_BUTDAD = result.GetValue("BUTDAD")

	doc.l_BUTDTU = result.GetValue("BUTDTU")

	doc.l_BUAVAD = result.GetValue("BUAVAD")

	doc.l_BUAVTU = result.GetValue("BUAVTU")

	doc.l_BUAYAD = result.GetValue("BUAYAD")

	doc.l_BUAYTU = result.GetValue("BUAYTU")

	doc.l_BUODTU = result.GetValue("BUODTU")

	doc.l_BUADTU = result.GetValue("BUADTU")

	doc.l_BUMIAD = result.GetValue("BUMIAD")

	doc.l_BUMITU = result.GetValue("BUMITU")

	doc.l_BUTFTU = result.GetValue("BUTFTU")

	

	doc.l_BUUSR = result.GetValue("BUUSR")

	doc.l_BUDSP = result.GetValue("BUDSP")

	doc.l_BUPGM = result.GetValue("BUPGM")

	doc.l_BUTRH = result.GetValue("BUTRH")

	doc.l_BUTIM = result.GetValue("BUTIM")

	

	Call doc.Save( True, True )

	result.NextRow

Loop



result.Close(DB_CLOSE)

con.Disconnect	

End Sub

Subject: reading records from db2 via iSeries ODBC Driver

try adding this right after your qry.SQL line:

If result.IsResultSetAvailable Then

	result.LastRow		

	result.FirstRow						

Else 

	Print "Result set not available!"

	Exit Sub

End If

Subject: RE: reading records from db2 via iSeries ODBC Driver

I added what you said. And it printed “Result set not available!”. What does that mean?

Subject: RE: reading records from db2 via iSeries ODBC Driver

your missing a result.Execute:try this:

result.Execute





If result.IsResultSetAvailable Then

	result.LastRow		

	result.FirstRow						

Else 

	Print "Result set not available!"

	Exit Sub

End If

HTH

ST

Subject: RE: reading records from db2 via iSeries ODBC Driver

Thanks for quick responses. I did what you suggested. It doesn’t give any error this time after I put your code correct place :slight_smile: . But I could still less data than DB2 has. Something strange on 2312 nd record. If there are less records than 2312, I can pull the data successfuly. What else can I try?