| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
What kind of database? What are you using to connect, read, and write to it with?
|
|
#3
|
|||
|
|||
|
sqldmo is the database
Quote:
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. |
|
#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 |
|
#5
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > size of the database in VC++ |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|