ODBC / WINDOWS NT problem!
Kavita Chinta -- kavita@headcheese.daa.uc.EDU
Friday, January 03, 1997
Environment: Windows NT 4.0, VC++ 4.2-flat
Hello,
I am having a problem with an ODBC application on WINDOWS NT.
My application has a CDatabase object in my main application class.
In my view class I have a message handler which will get a pointer
to my application class. I then open the CDatabase object by passing
"NULL" as the parameter as I want the user to select the
data source. Now my problem is my application works fine for
the first time and then say after three or four times it crashes.
This problem does not happen on WINDOWS 95. I ran the same
application on a WIN 95 machine and it worked fine. Does ODBC
work differently for WIN NT?? Did anyone have a similar problem?
The code in my message handler is as shown below:
void CTestDBView::OnViewTest()
{
// TODO: Add your command handler code here
CTestDBApp* papp = (CTestDBApp*) AfxGetApp();
if (papp->m_db.IsOpen() )
papp->m_db.Close();
if (!papp->m_db.OpenEx(NULL) )
MessageBox("Error");
else
{
CString p;
p = papp->m_db.GetConnect();
p = p.Right(p.GetLength() - (p.Find(_T("DSN")) + 4));
p = p.Left(p.Find(_T(";")));
AfxMessageBox(p);
}
}
Anyhelp regarding this is appreciated. Thanks in advance,
Kavita Chinta
Software Synergy Inc.
Cincinnati,
OH - 45241
Dan Kirby -- dkirby@accessone.com
Saturday, January 04, 1997
Hi,
You don't have very much information in your message so I can only take a
wild guess. As I look into my crystal ball, I see that you most likely
need the newer Jet DLL component which is talked about in article Q151186.
To get to the Microsoft Developer Knowledgebase go to
http://www.microsoft.com/kb. This takes care of a crashing problem when
shutting down connections and it most often occurs on NT 4.0.
You message doesn't talk about when the crash occurs or what you mean by
crash (access violation, exception, assertion, etc.).
--dan
----------
> From: Kavita Chinta
> To: mfc-l@netcom.com
> Subject: ODBC / WINDOWS NT problem!
> Date: Friday, January 03, 1997 12:55 PM
>
>
> Environment: Windows NT 4.0, VC++ 4.2-flat
>
> Hello,
> I am having a problem with an ODBC application on WINDOWS NT.
> My application has a CDatabase object in my main application class.
> In my view class I have a message handler which will get a pointer
> to my application class. I then open the CDatabase object by passing
> "NULL" as the parameter as I want the user to select the
> data source. Now my problem is my application works fine for
> the first time and then say after three or four times it crashes.
> This problem does not happen on WINDOWS 95. I ran the same
> application on a WIN 95 machine and it worked fine. Does ODBC
> work differently for WIN NT?? Did anyone have a similar problem?
> The code in my message handler is as shown below:
>
>
> void CTestDBView::OnViewTest()
> {
> // TODO: Add your command handler code here
> CTestDBApp* papp = (CTestDBApp*) AfxGetApp();
> if (papp->m_db.IsOpen() )
> papp->m_db.Close();
>
> if (!papp->m_db.OpenEx(NULL) )
> MessageBox("Error");
> else
> {
> CString p;
> p = papp->m_db.GetConnect();
> p = p.Right(p.GetLength() - (p.Find(_T("DSN")) +
4));
> p = p.Left(p.Find(_T(";")));
> AfxMessageBox(p);
> }
>
>
>
> }
>
> Anyhelp regarding this is appreciated. Thanks in advance,
>
> Kavita Chinta
> Software Synergy Inc.
> Cincinnati,
> OH - 45241
>
>
Christopher -- ckrahe@gshs.com
Monday, January 06, 1997
Kavita-
Environment: Windows NT 3.51, VC++ 4.2-Enterprise
We haven't seen a difference ODBC-wise between NT & 95. We pass a
non-null string to Open with empty parameter values, eg: "ODBC;DSN=",
which for us gives the results you are looking for (the user is prompted
to select a datasource). We haven't tried passing NULL like the
documentation says you can. Note that we're using Open instead of
OpenEx, though I am not sure whether that makes a difference.
BTW, does anyone know why the MFC documentation reads "Calling the OpenEx
member function is the preferred way to connect to a data source and
initialize your database object." ? Not suprisingly, it doesn't explain
why.
-Chris Krahe
Columbia, MD
--------------------------
Environment: Windows NT 4.0, VC++ 4.2-flat
Hello,
I am having a problem with an ODBC application on WINDOWS NT.
My application has a CDatabase object in my main application class.
In my view class I have a message handler which will get a pointer
to my application class. I then open the CDatabase object by passing
"NULL" as the parameter as I want the user to select the
data source. Now my problem is my application works fine for
the first time and then say after three or four times it crashes.
This problem does not happen on WINDOWS 95. I ran the same
application on a WIN 95 machine and it worked fine. Does ODBC
work differently for WIN NT?? Did anyone have a similar problem?
The code in my message handler is as shown below:
void CTestDBView::OnViewTest()
{
// TODO: Add your command handler code here
CTestDBApp* papp = (CTestDBApp*) AfxGetApp();
if (papp->m_db.IsOpen() )
papp->m_db.Close();
if (!papp->m_db.OpenEx(NULL) )
MessageBox("Error");
else
{
CString p;
p = papp->m_db.GetConnect();
p = p.Right(p.GetLength() - (p.Find(_T("DSN")) +
4));
p = p.Left(p.Find(_T(";")));
AfxMessageBox(p);
}
}
Anyhelp regarding this is appreciated. Thanks in advance,
Kavita Chinta
Software Synergy Inc.
Cincinnati,
OH - 45241
Dan Kirby -- dkirby@accessone.com
Monday, January 06, 1997
Hi you wrote:
> BTW, does anyone know why the MFC documentation reads "Calling the OpenEx
> member function is the preferred way to connect to a data source and
> initialize your database object." ? Not suprisingly, it doesn't explain
> why.
Basically it is like any of the xxxxxEx functions in Windows. It is the API
that you know will be supported in the future. It also provides more
functionality. For example, the OpenEx function allows you to suppress the
ODBC login dialog and does not load the cursor library by default like the
Open() function does. So as it says, OpenEx is the preferred way to open a
CDatabase object because it is more flexible like most xxxxxEx functions.
--dan
----------
> From: Krahe, Christopher
> To: mfc-l@netcom.com
> Subject: Re: ODBC / WINDOWS NT problem!
> Date: Monday, January 06, 1997 5:21 AM
>
> Kavita-
>
> Environment: Windows NT 3.51, VC++ 4.2-Enterprise
>
> We haven't seen a difference ODBC-wise between NT & 95. We pass a
> non-null string to Open with empty parameter values, eg: "ODBC;DSN=",
> which for us gives the results you are looking for (the user is prompted
> to select a datasource). We haven't tried passing NULL like the
> documentation says you can. Note that we're using Open instead of
> OpenEx, though I am not sure whether that makes a difference.
>
> BTW, does anyone know why the MFC documentation reads "Calling the OpenEx
> member function is the preferred way to connect to a data source and
> initialize your database object." ? Not suprisingly, it doesn't explain
> why.
>
> -Chris Krahe
> Columbia, MD
>
> --------------------------
> Environment: Windows NT 4.0, VC++ 4.2-flat
>
> Hello,
> I am having a problem with an ODBC application on WINDOWS NT.
> My application has a CDatabase object in my main application class.
> In my view class I have a message handler which will get a pointer
> to my application class. I then open the CDatabase object by passing
> "NULL" as the parameter as I want the user to select the
> data source. Now my problem is my application works fine for
> the first time and then say after three or four times it crashes.
> This problem does not happen on WINDOWS 95. I ran the same
> application on a WIN 95 machine and it worked fine. Does ODBC
> work differently for WIN NT?? Did anyone have a similar problem?
> The code in my message handler is as shown below:
>
>
> void CTestDBView::OnViewTest()
> {
> // TODO: Add your command handler code here
> CTestDBApp* papp = (CTestDBApp*) AfxGetApp();
> if (papp->m_db.IsOpen() )
> papp->m_db.Close();
>
> if (!papp->m_db.OpenEx(NULL) )
> MessageBox("Error");
> else
> {
> CString p;
> p = papp->m_db.GetConnect();
> p = p.Right(p.GetLength() - (p.Find(_T("DSN")) +
> 4));
> p = p.Left(p.Find(_T(";")));
> AfxMessageBox(p);
> }
>
>
>
> }
>
> Anyhelp regarding this is appreciated. Thanks in advance,
>
> Kavita Chinta
> Software Synergy Inc.
> Cincinnati,
> OH - 45241
>
| Вернуться в корень Архива
|