C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 1st, 2005, 05:40 AM
jayender jayender is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 10 jayender User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 10 m 8 sec
Reputation Power: 0
Question size of the database in VC++

hi ,
how to find the size of the database before backing up the file in VC++?
i got to know the size from the Front end and not from the back end !!

thanks,
jayender

Reply With Quote
  #2  
Old June 1st, 2005, 09:11 AM
ShadowCoder ShadowCoder is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Ottawa
Posts: 20 ShadowCoder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 54 m 12 sec
Reputation Power: 0
What kind of database? What are you using to connect, read, and write to it with?

Reply With Quote
  #3  
Old June 2nd, 2005, 01:48 AM
jayender jayender is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 10 jayender User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 10 m 8 sec
Reputation Power: 0
sqldmo is the database

Quote:
Originally Posted by ShadowCoder
What kind of database? What are you using to connect, read, and write to it with?


Hi ,
Iam using SQL DMO,
i have done backup and restoreing the database in VC++(MFC),
but i need to know the size of the file before backing up the file , because if i nedd to store the backed up database in CD then i got to know the size of the backup file before backup to know the avalability of the space .

waiting for ur reply
thanks,
Jayender.

Reply With Quote
  #4  
Old June 8th, 2005, 09:37 AM
Cirus Cirus is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 276 Cirus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 11 h 48 m 58 sec
Reputation Power: 4
For database file only, I suggest for knowing file size through file properties. But this approach can ive false result owing to partition format of your hard disk.i.e if your disk is formatted using FAT16 or NTFS, file size would differ.

In VC++ there is a function GetFileSize that lets you determine file size. All you have to do is to write a seperate utility that does back up of database file to a disk by pre-determining its size using the said function.

HTH

Reply With Quote
  #5  
Old June 16th, 2005, 05:39 AM
jayender jayender is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 10 jayender User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 10 m 8 sec
Reputation Power: 0
Thumbs up

here is the solution .. i got just a hour ago...

{
LPSQLDMODATABASES pDatabases = NULL;
LPSQLDMODATABASE pDatabase = NULL;
LPSQLDMOFILEGROUPS pFileGroups = NULL;
LPSQLDMOFILEGROUP pFileGroup = NULL;
LPSQLDMOSERVER pFileName = NULL;

LONG lCount = 0;
LPSQLDMODBFILE ppDBFile = NULL;
LPLONG pRetVal = NULL;
long m_datasize;

CString temp;
CString name;
CString freesize;
CString temporder;

CString datasize;
CString FreesizeMB;

// pSQLServer->GetDatabaseCount(&lCount);

hr = pSQLServer->GetDatabases(&pDatabases);

// for (LONG i = 0; i < 1; i++)
// {
// pFileName->GetDatabaseByName(myview->strDB,0);

pDatabases->GetItemByOrd(1,&pDatabase);

// pDatabase->GetName(&myview->strDB);

pDatabase->Release();

pDatabase->GetFileGroups(&pFileGroups);

float m_datasizeMB;

pDatabase->GetSpaceAvailableInMB(&m_datasizeMB);

pDatabase->GetSize(&m_datasize);

pDatabase->GetFileGroupByName(/*(L"DOTS")*/0,&pFileGroup);

pFileGroups->GetItemByOrd(0,&pFileGroup);

pFileGroup->GetDBFileByOrd(0,&ppDBFile);

float pval;

long m_long;

ppDBFile->GetSizeInKB(&pval);

ppDBFile->GetSpaceAvailableInMB(&m_long);
freesize = _T(m_datasizeMB);
datasize.Format("%lf",pval);
FreesizeMB.Format("%lf",m_datasizeMB);

ppDBFile->GetPhysicalName(&myview->strDB);

CString dataname (myview->strDB);

AfxMessageBox(dataname);

SetDlgItemText(IDC_EDIT1,datasize);

AfxMessageBox(datasize);

AfxMessageBox(FreesizeMB);
}

regards,
Jayender

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > size of the database in VC++


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT