How to connect JDE database by using ODBC in Visual Basic?

From access 97 help on the recordcount property:


Use the RecordCount property to find out how many records in a Recordset or TableDef object have been accessed. The RecordCount property doesn't indicate how many records are contained in a dynaset-, snapshot-, or forward-only–type Recordset object until all records have been accessed. Once the last record has been accessed, the RecordCount property indicates the total number of undeleted records in the Recordset or TableDef object. To force the last record to be accessed, use the MoveLast method on the Recordset object. You can also use an SQL Count function to determine the approximate number of records your query will return.


You are probably retrieving records - however the code you have here isn't doing anything - try changing that msgbox to return the first field of the table

You're going to need some code like:

' while we haven't attempted to go past the last record
While Not rs.EOF
your processing goes here

' move to the next record
rs.MoveNext
Wend

' cleanup code here...


You can count the record manually during this loop or change the recordset property.

Dave
 
I had connected to JDE Database successfully.

The following is my coding.

Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
Set cmd = New Command

conn.CursorLocation = adUseClient
conn.ConnectionString = "DSN=Business Data - CRP;UID=JDESMS;PWD=jdesms"
conn.Open

rs.CursorType = adOpenStatic

Set cmd.ActiveConnection = conn

cmd.CommandText = "Select * from F41021 "
cmd.CommandType = adCmdText
Set rs = cmd.Execute

Set rs = Nothing
Set cmd = Nothing
conn.Close
Set conn = Nothing



Cursor Location and Cursor type must included so that the record count won't be -1.

hope can help u all

thanks alot for your help
 
Back
Top