Re: Check if a record with a specific ID exists in a table
Posted 28 April 2012 - 07:39 AM
I would guess that even though the result set has no data, the meta-data for the result set is being sent, including the number of fields should be in each row.
But I would question your method there. Why, if you are only interested in seeing if the row exists, are you attempting to fetch all the data in the row? Unless you actually need the data, you should not be fetching it. It's a waste of resources. - Instead, use the COUNT() function to see how many rows there are.
I'm no VB coder, but I'd imagine it being something like this:
rs.Open "SELECT COUNT(*) FROM tblTransaction WHERE TransactionID = 1", DBConn
Set rowCount = CInt(rs(0))