Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SQLRowCount() returning -1 for SELECT statement

Author  Topic 

ishwarbg
Starting Member

4 Posts

Posted - 2007-11-15 : 00:30:59
Hi friends,
I am facing problem with SQLRowCount() function which is returning -1 when I tried to fetch records greater than 99 from my data file. if the data file contains total of 99 records then the above function is returning its second parameter value nRowCount as 99 but if dat file contains 100 records then it is returning nRowCount as -1
Please tell me whether it is a driver specic error or some thing else. I am using a ODBC driver for a database called MYOB.

Below are the SQL APIs that I used in my code.


if (SQLExecDirect(m_StmtHandle, (PUCHAR)sExecuteStatement.c_str(), SQL_NTS) != SQL_SUCCESS) return false;

if (SQLRowCount(m_StmtHandle,&nRowCount) != SQL_SUCCESS) return false;

The string 'sExecuteStatement' in SQLExecDirect() function above is carrying a Select query.


Its an unpredictable error because the function fails to return exact row count for 100 records, but it is working fine with 99 records.

I am not using any kind of array with size of 99 or 100 in my code.

What I want to know is:

1. Can I use SQLRowCount() with SELECT statement, If not what is the alternative.

2. Is this a driver specific error?.

3. Can I use SQL_DIAG_ROW_COUNT instead of SQLRowCount? If Yes, How to use it?.

Your help will be greatly appriciated if you give me a piece of code for this issue.





Ishwar B.G

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2007-11-15 : 01:47:29
What platform and what API are you using?
Go to Top of Page

ishwarbg
Starting Member

4 Posts

Posted - 2007-11-15 : 02:37:01
I am working in Windows XP. The functions that I listed in my request query above are belongs to SQL_API from SQL.H header.

Ishwar B.G
Go to Top of Page

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2007-11-15 : 04:13:44
quote:

ishwarbg

I am using a ODBC driver for a database called MYOB.


MYOB isn't SQL Server is it?

Em
Go to Top of Page

ishwarbg
Starting Member

4 Posts

Posted - 2007-11-15 : 04:38:42
Hi,
Yes you are right. My client is using his own data base called MYOB with their own data base drivers.
Please treat my query as a general question and provide me the possible solution. I think the SQL API used in my code are also used for other data bases like SQL Server. If I am wrong please advice.

Ishwar B.G
Go to Top of Page
   

- Advertisement -