RE: How do I use ADO in VC++ 7.0 to get the size of the database
- From: "MrSmersh" <MrSmersh@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 13 Jan 2006 07:08:03 -0800
I did found in my source code a code snippet doing something like this.
Most of the trick is to specify adCmdStoredProc as command parameter the
command will return a record set.
And using a store procedure to find database size I found that is the best
way.
Hope it answers your question.
CString sConString,sDBName;
try
{
_ConnectionPtr pConn("ADODB.Connection");
_CommandPtr pCmd("ADODB.Command");
_RecordsetPtr pRstDBs("ADODB.Recordset");
_variant_t vtEmpty (DISP_E_PARAMNOTFOUND, VT_ERROR);
_variant_t vtEmpty2(DISP_E_PARAMNOTFOUND, VT_ERROR);
//Real connection string
sConString=””;
_bstr_t bstrConString(sConString);
pConn->Open(bstrConString, "", "", adConnectUnspecified);
try
{
_bstr_t bstrCommand("sp_helpdb");
pCmd->ActiveConnection = pConn;
pCmd->CommandType = adCmdStoredProc;
pCmd->CommandText = bstrCommand;
pRstDBs = pCmd->Execute( &vtEmpty, &vtEmpty2,adCmdUnknown );
if(!pRstDBs->EndOfFile||!pRstDBs->BOF)
{
for(;!pRstDBs->EndOfFile;pRstDBs->MoveNext())
{
sDBName=(V_BSTR(&pRstDBs->Fields->GetItem( _variant_t( 0L ) )->Value));
}
}
pRstDBs->Close();
}
catch(_com_error &Err)
{
pConn->Close();
}
pConn->Close();
"Kjell Arne Johansen" wrote:
> How do I use ADO in VC++ 7.0 to get the size of the database.
> I know that sp_helpdb <database> returns size information.
> But how do I retrieve this information in my code?
>
> In my code I'm using _ConnectionPtr to execute commands,
> e.g. m_pConnection->Execute("EXEC procDoSomething", NULL, adExecuteNoRecords);
>
> Can I use m_pConnection to get the return value from a "sp_helpdb
> <database>" command?
>
> Are there other ways to retrieve the database size in Visual C++ using ADO?
>
> Regards
> Kjell Arne Johansen
>
.
- Prev by Date: Re: Command object stops prematurely w/o failure
- Next by Date: Can't instanciate Errors object in C++/MFC dialog app == :-(
- Previous by thread: Re: Command object stops prematurely w/o failure
- Next by thread: Can't instanciate Errors object in C++/MFC dialog app == :-(
- Index(es):
Relevant Pages
- Re: SET IDENTITY_INSERT tablename ON problem
... Try to do next - run SQL profiler and see if ADO Command ... Another way is
to use Execute method of ADO connection. ... > database I add a new tmp table
with the new structure. ... (microsoft.public.vb.database.ado) - RE: Event ID 447
... Please made a backup for Exchange database first. ... Please run the eseutil
/mh command to see if the mailbox store is clean ... Microsoft CSS Online Newsgroup
Support ... (microsoft.public.windows.server.sbs) - Re: Sharepoint Database falling over event 1000
... Microsoft Small Business Server Support ... > I Have Just run the SQL
command from the command Line, ... > affected)1> exitDoes this say the database
is Ok?If so why since we loaded ... > I/O operation has been aborted because ofeither a thread
exit or an ... (microsoft.public.windows.server.sbs) - Re: Too many args when running a stored procedure
... Perhaps you have a duplicate definition of "AddAJob" in the master database schema.
... you don't show that you are associating the connection object with ... >>
it with the command object. ... >>> @Rate money ... (microsoft.public.dotnet.languages.vb) - Re: Please Urgent - Update Data Source Problem ???
... then there's nothing to submit to the database. ... values that are only assigned
by the DB once the update command is executed. ... > the connection. ...
> schedule, and they can update the existing schedule, add new schedule ... (microsoft.public.dotnet.framework.compactframework)