all groups > sql server msde > october 2005 >
You're in the

sql server msde

group:

NewBie, how to trap: SQLAllocHandle Error


NewBie, how to trap: SQLAllocHandle Error Rob Dob
10/30/2005 5:06:08 PM
sql server msde: I have a MFC VC7.1++ program using VS2003, and also using the MSDE2000 for
some reason my import is now failing and I cannot figure out why, before
today this first statement use to successfully process. The return value of
retcode now is 0, it use to be retcode = 1 I have looked up the
documentation and see confusing information at least to me as to what an
acceptable retcode should be, I even read of a macro SQL_SUCEEDED which
will accept both 1 and 0, but when I use this then it just steps thorugh me
code with no error, yet does NOT import the data into the table I wish.


SQLHENV henv = SQL_NULL_HENV;
HDBC hdbc1 = SQL_NULL_HDBC;
RETCODE retcode;
SDWORD cRows;
// Allocate the ODBC environment and save handle.
retcode = SQLAllocHandle (SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
if ( (retcode != SUCCEED) )
return;
}




Also I am calling retcode = bcp_init(hdbc1, "tempemailholder",
fdlg.GetPathName(),"c:\\BCPERROR.out", DB_IN)

retcode = 0 and no error file "c:\\BCPERROR" is created...

any help would be appreciated...

thanks

Re: NewBie, SQLAllocHandle only works on Win2003Server. Rob Dob
10/30/2005 5:27:00 PM
Hi,

I just did a test, this code returns 1 on a windows2003 Server system, and
my import works fine, however if I run this same code on a WinXP, Pro or XP
Media it then returns 1 and the import does NOT work...

Please any suggestions would be creatly appreciated..

where should I start looking.?

retcode = 1 when running on Server 2003
retcode = 0 when running on WinXP Pro or WinXP Media


SQLHENV henv = SQL_NULL_HENV;
HDBC hdbc1 = SQL_NULL_HDBC;
RETCODE retcode;
SDWORD cRows;
// Allocate the ODBC environment and save handle.
retcode = SQLAllocHandle (SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
if ( (retcode != SUCCEED) )
return;
}


Re: NewBie, SQLAllocHandle only works on Win2003Server. Joe Butler
10/31/2005 2:03:41 AM
SQLAllocHandle() returns various status codes, and more than one of them
mean "success". You need to check your return value against each of these
codes and handle it - not just SUCCEED (which wasn't mentioned in the docs,
btw).



[quoted text, click to view]

AddThis Social Bookmark Button