Click here to Skip to main content
14,875,778 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Passing a "value", that was either #defined or #undef, into a macro and check if it was defined? Pin
arnold_w9-Oct-19 9:18
Memberarnold_w9-Oct-19 9:18 
QuestionString Table MFC vc++ Pin
Member 145755569-Oct-19 1:59
MemberMember 145755569-Oct-19 1:59 
AnswerRe: String Table MFC vc++ Pin
Member 145755569-Oct-19 2:04
MemberMember 145755569-Oct-19 2:04 
GeneralRe: String Table MFC vc++ Pin
Maximilien9-Oct-19 22:00
MemberMaximilien9-Oct-19 22:00 
GeneralRe: String Table MFC vc++ Pin
Member 145755569-Oct-19 22:20
MemberMember 145755569-Oct-19 22:20 
QuestionSingleton Design Pattern for Database connection in MFC vc++ Pin
Member 145755566-Oct-19 18:24
MemberMember 145755566-Oct-19 18:24 
AnswerRe: Singleton Design Pattern for Database connection in MFC vc++ Pin
_Flaviu6-Oct-19 19:38
Member_Flaviu6-Oct-19 19:38 
GeneralRe: Singleton Design Pattern for Database connection in MFC vc++ Pin
Member 145755566-Oct-19 21:29
MemberMember 145755566-Oct-19 21:29 
I have created like this. Am I going in the right direction?
Thanks in advance.


#include <afxdb.h>

#pragma once

// DatabaseSingleton command target

class DatabaseSingleton : public CDatabase
{
	static DatabaseSingleton* _instance;
	DatabaseSingleton();
public:
	//DatabaseSingleton();
	static DatabaseSingleton* GetInstance();
	virtual ~DatabaseSingleton();
private:
	CString DSN;
	CString UID;
	CString PWD;
	CString ConnectionString;
};


// DatabaseSingleton.cpp : implementation file
//

#include "stdafx.h"
#include "Medication_Administration.h"
#include "DatabaseSingleton.h"


// DatabaseSingleton

DatabaseSingleton::DatabaseSingleton():DSN(_T("DemoDB")),UID(_T("root")),PWD(_T("root"))
{
	ConnectionString.Format(_T("DSN=%s;UID=%s;PWD=%s"), DSN, UID, PWD);
	OpenEx(ConnectionString);
}

DatabaseSingleton::~DatabaseSingleton()
{
	Close();
}


// DatabaseSingleton member functions
DatabaseSingleton* DatabaseSingleton::GetInstance()
{
	if (_instance == NULL)
	{
		_instance = new DatabaseSingleton();
	}
	return _instance;
}

GeneralRe: Singleton Design Pattern for Database connection in MFC vc++ Pin
_Flaviu6-Oct-19 21:55
Member_Flaviu6-Oct-19 21:55 
GeneralOT Pin
Richard MacCutchan6-Oct-19 23:03
mveRichard MacCutchan6-Oct-19 23:03 
GeneralRe: OT Pin
_Flaviu6-Oct-19 23:32
Member_Flaviu6-Oct-19 23:32 
GeneralRe: OT Pin
Richard MacCutchan7-Oct-19 2:35
mveRichard MacCutchan7-Oct-19 2:35 
Questionidentifier 'mode_t' Pin
_Flaviu6-Oct-19 8:08
Member_Flaviu6-Oct-19 8:08 
AnswerRe: identifier 'mode_t' Pin
Victor Nijegorodov6-Oct-19 9:57
MemberVictor Nijegorodov6-Oct-19 9:57 
GeneralRe: identifier 'mode_t' Pin
_Flaviu6-Oct-19 10:08
Member_Flaviu6-Oct-19 10:08 
GeneralRe: identifier 'mode_t' Pin
Richard MacCutchan6-Oct-19 22:30
mveRichard MacCutchan6-Oct-19 22:30 
SuggestionRe: identifier 'mode_t' Pin
David Crow6-Oct-19 11:48
MemberDavid Crow6-Oct-19 11:48 
Questionerror C2678 Pin
_Flaviu4-Oct-19 4:54
Member_Flaviu4-Oct-19 4:54 
QuestionRe: error C2678 Pin
Richard MacCutchan4-Oct-19 5:09
mveRichard MacCutchan4-Oct-19 5:09 
AnswerRe: error C2678 Pin
_Flaviu5-Oct-19 22:53
Member_Flaviu5-Oct-19 22:53 
GeneralRe: error C2678 Pin
Richard MacCutchan5-Oct-19 23:12
mveRichard MacCutchan5-Oct-19 23:12 
GeneralRe: error C2678 Pin
_Flaviu5-Oct-19 23:50
Member_Flaviu5-Oct-19 23:50 
GeneralRe: error C2678 Pin
Richard MacCutchan6-Oct-19 0:04
mveRichard MacCutchan6-Oct-19 0:04 
GeneralRe: error C2678 Pin
_Flaviu6-Oct-19 5:20
Member_Flaviu6-Oct-19 5:20 
GeneralRe: error C2678 Pin
Richard MacCutchan6-Oct-19 5:34
mveRichard MacCutchan6-Oct-19 5:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.