Click here to Skip to main content
15,896,726 members
Articles / Desktop Programming / WTL

Shrinking SQL Server Transaction Logs with SQL-DMO

Rate me:
Please Sign up or sign in to vote.
4.99/5 (49 votes)
21 Apr 2004CPOL9 min read 206.2K   4.7K   70  
Using SQL-DMO to shrink SQL Server transaction logs.
/////////////////////////////////////////////////////////////////////////////

#include "StdAfx.h"
#include "Dialogs.h"
#include "VerInfo.h"
#include "Resource.h"

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg

CAboutDlg::CAboutDlg( void ) 
		 : CDialog( CAboutDlg::IDD )
{
}

void CAboutDlg::DoDataExchange( IN CDataExchange* pDX )
{
	CDialog::DoDataExchange( pDX );
}

BEGIN_MESSAGE_MAP( CAboutDlg, CDialog )
END_MESSAGE_MAP()

BOOL CAboutDlg::OnInitDialog( void )
{
	BOOL bRetval = CDialog::OnInitDialog();
	CenterWindow();

	CFileVersionInfo fvi;
	if( fvi.Open( AfxGetInstanceHandle() ) )
	{
		TCHAR szTmp[ MAX_PATH ] = { 0 };

		VS_FIXEDFILEINFO vffi = fvi.GetVSFFI();
		::wsprintf( 
			szTmp, _T( "Version %d.%d Build %d" ), 
			HIWORD( vffi.dwFileVersionMS ),
			LOWORD( vffi.dwFileVersionMS ),
			HIWORD( vffi.dwFileVersionLS )
		);

		SetDlgItemText( IDC_LBL_APP_TITLE, AfxGetAppName() );
		SetDlgItemText( IDC_LBL_APP_VERSION, szTmp );

		fvi.QueryStringValue( VI_STR_LEGALCOPYRIGHT, szTmp, MAX_PATH );
		SetDlgItemText( IDC_LBL_APP_COPYRIGHT, szTmp );

		fvi.QueryStringValue( VI_STR_COMPANYNAME, szTmp, MAX_PATH );
		SetDlgItemText( IDC_LBL_APP_COMPANY, szTmp );
	}

	return ( bRetval );
}

/////////////////////////////////////////////////////////////////////////////
// CBaseWizPg dialog

IMPLEMENT_DYNAMIC( CBaseWizPg, CPropertyPage )

CBaseWizPg::CBaseWizPg( IN UINT nIDTemplate )
		  : CPropertyPage( nIDTemplate )		  
{
	m_psp.dwFlags |= PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
	m_psp.dwFlags &= ~PSP_HASHELP;
}

CBaseWizPg::~CBaseWizPg( void )
{
}

BOOL CBaseWizPg::OnInitDialog( void )
{
	BOOL bRetval = CPropertyPage::OnInitDialog();

	m_pPsh = (CWizPsh*)GetParent();
	if( m_pPsh == NULL )
		return ( FALSE );

	return ( bRetval );
}

BOOL CBaseWizPg::OnSetActive( void ) 
{
	BOOL bRetval = CPropertyPage::OnSetActive();
	
	ASSERT( m_pPsh != NULL );
	m_pPsh->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
	
	TrimWorkingSet();

	return ( bRetval );
}

void CBaseWizPg::ResetToDefaults( void )
{
}

BOOL CBaseWizPg::CheckDlgItemText( IN INT nDlgItemID )
{
	ASSERT( IS_INTRESOURCE( nDlgItemID ) );
	
	CWnd* pWnd = GetDlgItem( nDlgItemID );
	ASSERT( pWnd != NULL );

	if( pWnd )
	{
		if( pWnd->GetWindowTextLength() > 0 )
			return ( TRUE );

		CString strMsg, strParam;		
		strParam.LoadString( nDlgItemID );
		AfxFormatString1( strMsg, IDP_INVALID_STR, strParam );
		
		AfxMessageBox( strMsg );		
		pWnd->SetFocus();
	}

	return ( FALSE );
}

/////////////////////////////////////////////////////////////////////////////

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) SafeNet Inc
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions