Click to See Complete Forum and Search --> : sqlAllocEnv APi Not Working


Bill Crawley
September 30th, 2005, 04:04 AM
Hi All,

I have the following declaration:

<DllImport("odbc32.dll", BestFitMapping:=True, CallingConvention:=CallingConvention.ThisCall, _
CharSet:=CharSet.Unicode, EntryPoint:="SQLAllocEnv", ExactSpelling:=True)> _
Public Shared Function SQLAllocEnv(ByVal phenv As Integer) As Short
'leave this function empty
End Function


I cannot seem to get this to work.

If I have CallingConvention set to StdCall, then I receive a return code of -1.
If I set it to ThisCall, I receive a return code of 0. Any other value either gives -1 or crashes.

In all cases the handle is always 0 ??? So the above is the nearest I have got to making it work. Anybody have any ideas?