Solved

LoadNetlibs exception

Posted on 2001-08-02
8
479 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
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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need some help with listview limit text 20 104
Fast access to array, using indexes, smart iterative search 2 112
FMX enumerated colours 2 101
Best book to learn C++ 4 79
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

810 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