The API function dynamically establishes an ODBC data source in Delphi.

zhaozj2021-02-16  48

In the process of pouring data during the previous time item, it is required to dynamically encounter with the data source that is related to data sources. Of course, the DBF table (unloaded version of the patch can not be connected), and then discovery can be connected. Connection processing, then ODBC must dynamically establish the possibility of removing the user to remove ODBC. Here I write the API function prototype and the statement to build SQLSERVER and DBF tables. (Of course, SQL Server does not have to be established in ADO).

SqlconfigDataSource (HWndParent: Integer; FREQUEST: Integer; lpszdriverstring: string; lpszattributes: string: integer;

Use in the call state:

Function SQLConfigDataSource (HWndParent: Integer; Frequest: Integer; lpszdriverstring: string; lpszattributes: string: integer; stdcall; external 'odbccp32.dll';

Establish SQLServer's ODBC:

SqlconfigDataSource (0, ODBC_ADD_SYS_DSN, 'SQL Server', 'DSN = Record_oDBC' CHR (0) 'Server = (local)' CHR (0) 'Database = Master' CHR (0) 'Description = DragonPC SQLSERVER ODBC SOURCE ' CHR (0));

{DSN: Your ODBC Data Source Name.

Server: Your database server name, use (local) refers to a database installed by the local computer. Note: The latest SQL Server 2000 supports a computer running multiple SQL Server services, this time you need to specify the SQLSever's InstanceName.

Address: Specifies the network IP address of the SQL Server server.

Database: Specify the default database name.

Language: Specifies the default language.

Description: Remarks Information. }

Establish DBF Table ODBC:

SQLConfigDataSource (0, ODBC_ADD_SYS_DSN, 'Microsoft Visual FoxPro Driver' CHR (0), 'dsn = SourceTable' CHR (0) 'BackgroundFetch = Yes' CHR (0) 'Description = descripcion de la conexion' CHR (0) 'Exclusive = NO' CHR (0) SourceDBSTR CHR (0) 'SourceType = DBF');

Other thunder, just establish a DBF table to debug a long time, write it, I hope that everyone will free to waste time.

Note: The above content is only for the first scholar to meet similar problems.

转载请注明原文地址:https://www.9cbs.com/read-26481.html

New Post(0)