Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create ODBC data source.
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00815796
Message ID:
00815804
Views:
11
Hi Ionut,
you can find below how to create and delete DBC,DBF sources programmatically
* CREATE VFP TABLE

* Code to create a new datasource to a VFP table.
   *
   * First you need to use the Declare DLL function to prototype the
   * SQLConfigDataSource function
   ***
   DECLARE Integer SQLConfigDataSource in odbccp32.dll Integer, ;
      Integer, String, String
   ***
   * Now you need to create a string containing the settings appropriate
   * to the driver you are using. The following is an example for the
   * Microsoft VFP ODBC driver accessing the customer.dbf file.
   ***
   settings="DSN=SOYKAN"+chr(0)+;
             "Description=myapp ODBC Driver"+chr(0)+;
             "SourceDB=e:\myapp\test.dbf"+chr(0)+;
             "SourceType=DBF"

   * Note: If you have spaces on either side of the equal sign (=), this
   * code will not work.
   ? SQLConfigDataSource(0,1,"Microsoft Visual FoxPro Driver",settings)

   ***
   * Now you can create a view to these datasources either through the view
   * designer or in code.
   *** 
   
***********
* CREATE DBC 

   DECLARE Integer SQLConfigDataSource in odbccp32.dll Integer, ;
      Integer, String, String
      
   settings="DSN=SOYKAN"+chr(0)+;
             "Description=MYapp ODBC Driver"+chr(0)+;
             "SourceDB=e:\myapp\myapp.dbc"+chr(0)+;
             "SourceType=DBC"

   ? SQLConfigDataSource(0,1,"Microsoft Visual FoxPro Driver",settings)

* Delete ODBC SOURCE

DECLARE Integer SQLConfigDataSource IN odbccp32.dll Integer, ;
      Integer, String, String
   DriverName="Microsoft Visual FoxPro Driver"
   IsRemove =SQLConfigDataSource(1,3,DriverName, "DSN=SOYKAN" + CHR(0)+;
               "Description=SOYKAN TEST"+CHR(0)+;
               "SourceDB=C:\TEMP\data1.dbc"+CHR(0)+;
               "SourceType=DBC")
   IF IsRemove>0
      WAIT WINDOW "Deleted"
   ELSE
      WAIT WINDOW "Delete failed"
   ENDIF 
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform