📄 connectionprops.h
字号:
// ConnectionProps.h: interface for the CConnectionProps class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CONNECTIONPROPS_H__08E358EB_8056_11D2_A183_006008BF6F6C__INCLUDED_)
#define AFX_CONNECTIONPROPS_H__08E358EB_8056_11D2_A183_006008BF6F6C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifdef ODBDC_SUPPORT
#ifndef __AFXDB_H__
#include <afxdb.h>
#endif
class CDatabase;
#else
class ATL::CDataSource;
class ATL::CSession;
#endif
class CConnectionProps : public CObject
{
DECLARE_SERIAL(CConnectionProps)
public:
CConnectionProps(bool bSaveInRegistry = true);
virtual ~CConnectionProps();
const CConnectionProps& operator =(const CConnectionProps& right);
void Copy(const CConnectionProps& right);
void SetDSN(LPCSTR dsn);
void SetUID(LPCSTR uid);
void SetPassword(LPCSTR pwd);
bool SaveSettings(LPCTSTR lpszAppSection = "Connection");
bool LoadSettings(LPCTSTR lpszAppSection = "Connection");
void SaveToFile(LPCSTR FileName);
bool LoadFromFile(LPCSTR FileName);
#ifdef ODBDC_SUPPORT
bool Connect(CDatabase& database, bool bShowDialog = true);
bool ReadProps(CDatabase& database);
bool ReadProps(const CString strConnectionString);
#else
ATL::CSession* GetSession();
ATL::CDataSource* GetDataSource();
bool Connect(ATL::CDataSource* pDataSource,CSession* pSession);
#endif
bool Connect();
void CloseConnection();
void ShowError(LPCSTR error);
// Overrides
virtual void Serialize(CArchive& ar);
CString StrToFile(LPCSTR str, bool sMark = true);
void FileToStr(CArchive& ar, CString& str, bool bPressMark = true);
public:
CString m_strDSN;
CString m_strServerName;
CString m_strDatabaseName;
CString m_strTableName;
CString m_strLoginName;
CString m_strPassword;
CString m_strIniFileName;
//
#ifndef ODBDC_SUPPORT
ATL::CSession m_Session;
ATL::CDataSource m_DataSource;
#endif
protected:
bool SaveSettings(LPCTSTR lpszAppSection,LPCTSTR lpszEntry,LPCTSTR lpszValue);
CString LoadSettings(LPCTSTR lpszAppSection,LPCTSTR lpszEntry);
public:
static LPCTSTR m_szDSNEntry;
static LPCTSTR m_szLoginNameEntry;
static LPCTSTR m_szDatabaseNameEntry;
static LPCTSTR m_szPasswordEntry;
static LPCTSTR m_szTableEntry;
static LPCTSTR m_szServerNameEntry;
protected:
bool m_bSaveInRegistry;
};
#ifndef ODBDC_SUPPORT
inline
ATL::CSession* CConnectionProps::GetSession()
{
return &m_Session;
}
inline
ATL::CDataSource* CConnectionProps::GetDataSource()
{
return &m_DataSource;
}
inline
bool CConnectionProps::Connect()
{
return Connect(&m_DataSource,&m_Session);
}
#endif
#endif // !defined(AFX_CONNECTIONPROPS_H__08E358EB_8056_11D2_A183_006008BF6F6C__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -