Click here to Skip to main content
15,886,518 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CString to CLongBinary Pin
Uwe Keim21-Aug-01 4:00
sitebuilderUwe Keim21-Aug-01 4:00 
GeneralRe: CString to CLongBinary Pin
Giles21-Aug-01 4:42
Giles21-Aug-01 4:42 
GeneralRe: CString to CLongBinary Pin
Uwe Keim21-Aug-01 4:51
sitebuilderUwe Keim21-Aug-01 4:51 
Generalwhats wrong here??about waveinreset!! Pin
hapcoer20-Aug-01 23:43
hapcoer20-Aug-01 23:43 
Generala simple question about global variable Pin
Gérald Mercet20-Aug-01 23:04
Gérald Mercet20-Aug-01 23:04 
GeneralRe: a simple question about global variable Pin
Christian Graus20-Aug-01 23:29
protectorChristian Graus20-Aug-01 23:29 
GeneralRe: a simple question about global variable Pin
Gérald Mercet20-Aug-01 23:43
Gérald Mercet20-Aug-01 23:43 
GeneralRe: a simple question about global variable Pin
Christian Graus20-Aug-01 23:53
protectorChristian Graus20-Aug-01 23:53 
Sure, I'm happy to try. One caveat - this is my first ADO app and my first serious ATL app ( not that I think you're using ATL, nor do you need to, the point is I'm not talking from years of experience when it comes to ADO Smile | :) )

In my header I do this:

private:
_ConnectionPtr m_Connection;

In my constructor I do this:

m_Connection = NULL;

Then I have a Connect method like this:

STDMETHODIMP CSAFileDB::Connect(BSTR DatabasePath)
{
m_DatabasePath = DatabasePath;

m_Connection.CreateInstance(__uuidof(Connection));

CComBSTR conStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=";
conStr.Append(DatabasePath);

bstr_t con(conStr);

TESTHR(m_Connection->Open(con, "", "", adConnectUnspecified));

return S_OK;
}

Ignore the ATL stuff, the point is just that I connect.

Then in other methods I start by checking if m_Connection == NULL. My reason is that if it *is* NULL I can connect with each call, which slows things down but makes my database stateless ( each call performs a complete action and relies on no other calls, a good thing for a COM object to be able to do, I'm thinking ).

This works fine, so I see no reason why it wouldn't do the same for you, assuming all your methods are in the one class.

Christian

Secrets of a happy marriage #27:

Never go to bed if you are mad at each other. It's more fun to stay up and fight.
GeneralRe: a simple question about global variable Pin
Malcolm McMahon21-Aug-01 0:36
Malcolm McMahon21-Aug-01 0:36 
Generalcrypt Pin
20-Aug-01 22:37
suss20-Aug-01 22:37 
GeneralRe: crypt Pin
Tim Deveaux21-Aug-01 6:15
Tim Deveaux21-Aug-01 6:15 
GeneralSerialization Pin
Nick Armstrong20-Aug-01 22:09
Nick Armstrong20-Aug-01 22:09 
GeneralRe: Serialization Pin
Niklas L20-Aug-01 22:32
Niklas L20-Aug-01 22:32 
GeneralHELP !!! CHARFORMAT2 and yHeight Pin
20-Aug-01 21:42
suss20-Aug-01 21:42 
GeneralMDI application Pin
The_Server20-Aug-01 21:14
The_Server20-Aug-01 21:14 
GeneralRe: MDI application Pin
Ulf Öhlén20-Aug-01 22:36
Ulf Öhlén20-Aug-01 22:36 
GeneralCompress Pin
20-Aug-01 20:21
suss20-Aug-01 20:21 
GeneralRe: Compress Pin
Christian Graus21-Aug-01 0:51
protectorChristian Graus21-Aug-01 0:51 
GeneralCOleDateTimeSpan wierdness.... Pin
Liam O'Hagan20-Aug-01 20:13
Liam O'Hagan20-Aug-01 20:13 
GeneralRe: COleDateTimeSpan wierdness.... Pin
Kelly Herald21-Aug-01 17:13
Kelly Herald21-Aug-01 17:13 
GeneralRe: COleDateTimeSpan wierdness.... Pin
Liam O'Hagan21-Aug-01 20:54
Liam O'Hagan21-Aug-01 20:54 
GeneralSome body Help me !!! Pin
quangpm09a20-Aug-01 15:16
quangpm09a20-Aug-01 15:16 
GeneralRe: Some body Help me !!! Pin
Sam C20-Aug-01 15:46
Sam C20-Aug-01 15:46 
QuestionIt's friggin HUGE! Is VC++ on crack? Pin
Todd Smith20-Aug-01 14:04
Todd Smith20-Aug-01 14:04 
AnswerRe: It's friggin HUGE! Is VC++ on crack? Pin
CodeGuy21-Aug-01 2:09
CodeGuy21-Aug-01 2:09 

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.