Solved

LoadNetlibs exception

Posted on 2001-08-02
8
485 Views
Last Modified: 2010-08-05
Sometimes the following exception occured when I Open a connection to an SQL server from a COM+ application:

<2001/08/02 18:26:58> COM EXCEPTION!
  File = f:\projects\qnet\qnetlib\sql7db.cpp
  Line = 65
  Mess = Connection object - Open. DSN: 'Provider=SQLOLEDB;Data Source=.;Initial Catalog=QNetDBWork'
  Code = 80004005
  Code meaning = Unspecified error
  Source = Microsoft OLE DB Provider for SQL Server
  Description = [DBNETLIB][ConnectionOpen (LoadNetlibs()).]

The sql7db.cpp lines (line 65 is the DUMP_EXCEPTION line).

CString dsn;
dsn.Format ("Provider=SQLOLEDB;Data Source=.;Initial Catalog=%s",database);
BSTR bdsn=dsn.AllocSysString ();
CString coms; coms.Format("Connection object - Open. DSN: '%s'",dsn);
try
{
  conn->Open (bdsn,(char *)(LPCSTR)user,(char *)(LPCSTR)password,0);
}
catch (_com_error &e)
{
DUMP_EXCEPTION((char *)(LPCSTR)coms,e);
::SysFreeString (bdsn);
conn_ok=FALSE;
}


What can be the problem ?
0
Comment
Question by:stewe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 200 total points
ID: 6345565
How are 'user' and 'password' declared? If they're CStrings, the line should read

 conn->Open (bdsn,(LPCTSTR)user,LPCTSTR)password,0);
0
 
LVL 1

Author Comment

by:stewe
ID: 6345651
Open needs LPCTSTR ? Not char * ?
Can it be a prob ?
0
 
LVL 86

Expert Comment

by:jkr
ID: 6345665
>>Open needs LPCTSTR ?

It takes char*, but 'CString::operator LPCTSTR()' is the one that actually converts a 'Cstring' into a char. By using '(char *)(LPCSTR)user', you're misusing a CString as a pointer - try it...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:stewe
ID: 6345748
I use the (char *)(LPCSTR) in my code many times.
There were no errors about it...
0
 
LVL 86

Expert Comment

by:jkr
ID: 6345757
>>I use the (char *)(LPCSTR) in my code many times.

That's not correct, even though you didn't have any errors (so far).

Hmm, did you try it for this case?
0
 
LVL 1

Author Comment

by:stewe
ID: 6345817

I haven't received that error yet (after modifying to LPCTSTR). But I'm debugging and trying. Later I'll write what happened.
But of course I'll see this question's comments.

  Stewe
0
 
LVL 11

Expert Comment

by:griessh
ID: 6842572
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to accept "jkr" comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points.
The link to the Community Support area is: http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 

Expert Comment

by:ComTech
ID: 6858046
After review, the proposed answer will be accepted by:

ComTech
Community Support Admin
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question