Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordcount -1

Status
Not open for further replies.

FatEric

IS-IT--Management
Nov 8, 2007
58
BE
Hi all,

I guess this question has been asked a lot, but i could not find a right solution.

I would like to know the recordcound of a recordset. So what I do is I open the connection like this (the 1 and 3 should solve the recordcount problem said some solutions):

rs.Open(sql, conn, 1, 3)

Then I have tried a lot of things...
-> rs.movelast
nr = rs.recordcount
-> nr = rs.recordcount (without rs.movelast)
-> if not rs.eof then
nr = rs.recordcount
end if
-> ...

But I always get -1.

Does someone know a solution?

Thanks in advance,

FatEric
 
Check the sql string, make sure that the selected data exist. Or maybe you can write it down here to help us finding a solution.

Regards,
mansii
 
Hi,

The sql string is correct, because I find some values. Because the recordcount always gave me -1 I did the following to see if there were some values:

sql = "SELECT DECIMAL(PEPENR), PENAM1 FROM PZW8DTA.PERSPF WHERE PEPENR LIKE '%" & TextBox1.Text() & "%' ORDER BY PEPENR"
Try
rs2.Open(sql, connAS400,
ADODB.CursorTypeEnum.adOpenDynamic,
ADODB.LockTypeEnum.adLockReadOnly)
da.Fill(dt, rs2)
DataGrid1.DataSource = dt
rs2.Close()
Catch ex As Exception
rs2.Close()
End Try

Then I get all users with the pe number I give in, so that works.

Now I have written to sql statement (one with a count(*)) so I get the number of values. But I really want to know why the recordcound does not work...

Greetz, FatEric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top