Problem with SQLFetch when fetching result of sp_spaceused
- From: "Ashutosh" <ashutosh_pund@xxxxxxxxx>
- Date: 13 Dec 2006 04:47:12 -0800
Hi all,
I have a problem executing a sp_spaceused on a database.
Please execute sp_spaceused on your local database so that further
discussion will be more easier to understand.
The code snippet is as follows :
SQLCHAR database_size[15];
SQLCHAR unused[15];
The database_size is member of first record set and
unused is member of second recordset returned by the sp_spaceused.
SQLINTEGER rlength;
retcode = SQLAllocHandle(SQL_HANDLE_STMT,hDBC,&hStmt);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
retcode = SQLExecDirect(hStmt,(unsigned char *)sqlCommand,
SQL_NTS);
retcode = SQLBindCol(hStmt,2, SQL_CHAR, (SQLPOINTER) &database_size,
sizeof(database_size),&rlength);
//Problem - was not able to bind any
column of the second recordset so not able to fetch the unused space.
if (retcode != SQL_SUCCESS )
{
AfxMessageBox("Error occured while binding");
}
CString csDatabase_size;
//The while loop below returns after the first iteration as only first
recordset is available and nothing is accessible of second recordset so
cant get 'unused' field :(
while ((retcode = SQLFetch(hStmt)) == SQL_SUCCESS)
{
stored the return
values of database_size and unused.
}
SQLFreeHandle(SQL_HANDLE_STMT, hStmt);
}
else
{
AfxMessageBox("error while allocating a statement handle");
}
So the Problem is :
Is there any way to access all recordsets returned by sp_spaceused
using ODBC APIs on C++?
Please reply.
Thanks in advance :)
-Ashutosh
.
- Follow-Ups:
- Re: Problem with SQLFetch when fetching result of sp_spaceused
- From: Chris Kushnir
- Re: Problem with SQLFetch when fetching result of sp_spaceused
- Prev by Date: Re: Row counts differ between VFP IDE and ODBC Code
- Next by Date: Re: Problem with SQLFetch when fetching result of sp_spaceused
- Previous by thread: Row counts differ between VFP IDE and ODBC Code
- Next by thread: Re: Problem with SQLFetch when fetching result of sp_spaceused
- Index(es):