A lot of people want to use D,but they only know MS SQL Server,what will help them to Learn D?

Regan Heath via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 1 03:00:18 PDT 2014


On Thu, 01 May 2014 09:56:49 +0100, FrankLike <1150015857 at qq.com> wrote:

> On Monday, 14 April 2014 at 17:13:56 UTC, FrankLike wrote:
>>
>>> My advice - use ODBC, it is the fastest way you may connect to the SQL  
>>> server, and you already have everything you need for that. :)
>>>
>>> Regards
>>
>> I have test the d\dmd2\windows\lib\odbc32.lib,the size is 4.5kb,
>> I test it by test.d(build :dmd test.d)
>> but find the error:
>> Error 42:Symbol Undefined _SQLFreeHandle at 8
>> Error 42:Symbol Undefined _SQLSetEnvAttr at 16
>> Error 42:Symbol Undefined _SQLAllocHandle at 12
>> Error 42:Symbol Undefined _SQLGetDiagRec at 32
>> -- errorlevel 4
>>
>   I have fixed the errors.
> The exe file only 210kb,it works very good.
>
> Where the errors is ?
> In the odbc32.def file.
> must set the all used function names.
> such as:
>   _SQLFreeHandle at 8 	= SQLFreeHandle

That's interesting.

Those functions are _stdcall, so should be exported from the lib as  
_<func>@<N>.

How did you declare them in arsd.mssql?

You should use extern(Windows) e.g.

extern(Windows) SQLRETURN SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE  
Handle);

The extern(Windows) tells DMD to look for _stdcall.
extern(C) tells it to look for _cdecl.

The difference boils down to who is responsible for cleaning up the stack  
after a function call.  _stdcall assumes the callee will cleanup the  
stack, _cdecl assumes the caller will.

R

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/


More information about the Digitalmars-d-learn mailing list