I have another question about ADO (using C++). I have searched the MSDN but I haven't found a answer to my question (maybe I'm just too stupid)... If I make a connection to my SQL Server there may occur some errors, but how to find out what went wrong ?
In terms of code I have e.g. something like that:
try
{
connection->Open(ConnectionString,Username,Password,ADODB::adConnectUnspecified);
...
}
catch (_com_error& e)
{
long numErrors = connection->Errors->Count;
for (long i=0; i<numErrors; i++)
{
ADODB::ErrorPtr pErr = connection->Errors->GetItem(i);
.....
}
}
Now I could get the error number by pErr->GetNumber().
But with which symbolic constant has this to be compared to find out which error occured ? I didn't find any...Or is there another better way to do this ?
P.S. I am using SQL Server 2005 Express
Take a look at this link for various ADO Error codes
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdconadoerrorreference.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdcsterrorvalueenum.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdconadoerrors.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adosql/adoprg03_59pr.asp
Hope this helps
|||Hi,yes it helps a little. But I saw this error collection before, and I wondererd how to check if e.g. the authenticaton was wrong. I didn't saw any symbolic constant for this. That's the reason why I posted here...|||
Download MDAC 2.8 SDK and you should see oledberr.h which should have the symbolic constants like "DB_SEC_E_AUTH_FAILED" (authentication failed) etc;
MDAC 28 SDK link - http://www.microsoft.com/downloads/details.aspx?familyid=5067faf8-0db4-429a-b502-de4329c8c850&displaylang=en
Also take a look at this link and download Oledberr.exe - http://support.microsoft.com/default.aspx?scid=kb;EN-US;q168354&GSSNB=1
Hope this helps
|||Ah that's exactly what I've searched for. Thanks a lot.I tested it by comparing this constants to the exceptions Error-value and it worked :)
I hope this is the right way
P.S. The second link doesn't work for me, but I think it's not that important. The first link was that what I was searching for.
No comments:
Post a Comment