请问在delphi中如何使用sqlconfigdatasource函数来动态配置odbc的数据源?
要求包含主机地址,数据库是sql server。
这么做要在程序中包含哪个文件?在集成环境中该如何设置呐?
如果没法找到包含这个函数的单元文件,那么作为dll函数导出使用,
代码中该如何写呐?

解决方案 »

  1.   

    delphi中没有声明自己声明一下就可以使用了。
    function SQLConfigDataSource(hwndParent: Integer; fRequest: Integer;lpszDriverString: String;
    lpszAttributes: String): Integer;stdcall; external 'odbccp32.dll' name 'SQLConfigDataSource';
      

  2.   

    SQLConfigDataSource(NULL, ODBC_ADD_DSN, 'SQL Server',
              'DSN=Record_ODBC\0'
              'Server=(local)\0'
              'Database=master\0'
              'Trusted_Connection=yes\0'
              'Description=DragonPC SQLServer ODBC Source\0');
    最后的一个参数针对不同的驱动程序会有不同的格式。请参看msdn.