>I am looking to change a bunch of users from fox tables on a network to SQL databases in SQL Server. Is there a way to do this without going to every single machine and setting up the ODBC drivers? I think the windows API above will allow me to do this. Can I call this API within VFP 5.0 and use SQL Server without making changes on individual machines?
>I already have the fox code running on several machines that do have the ODBC control panel set up.
Ed,
Try this:
DECLARE INTEGER SQLConfigDataSource IN odbccp32.dll INTEGER, INTEGER, STRING, STRING
lcType = 'SQL Server'
lcODBC = 'DSN=' + ALLTRIM( tcDSN) + CHR(0) + ;
'Server=' + ALLTRIM( tcPath) + CHR(0) + ;
'Database=' + ALLTRIM( tcDatabase) + CHR(0) + ;
'Description=' + ALLTRIM( tcDSN)
with tcDSN being the name of the data source, tcPath the name of the server, tcDatabase the name of the database and tcDSN a description
You need to delete the data source first and then re-add - in case it changes for example and to ensure it is correct each time
*-- delete it
SQLConfigDataSource( 0, 3, lcType, lcODBC)
*-- Add it
SQLConfigDataSource( 0, 1, lcType, lcODBC)
If it returns 0, then an error happened.
HTH
regards
Ian