Hi Sam
Glad it helped, here is more from good people on this forum and elsewhere I don't remember the original writer but here is my adaption for programatically setting up VFP ODBC. It is from my documentation for CodeBook62
[i-Level Change] Class | Add Property... | cPathToDBC | Properties | Other | cPathToDBC: ""
[i-Level Change] Class | Add Method... | SetupODBC | Properties | Methods | SetupODBC:
*-- The following are only needed for the VFP DSN Example.
*-- Modify to reflect the path to and name of your VFP DBC.
*-- Please note that a UNC path name is a supported feature.
#DEFINE DATABASE_NAME "vso3views.dbc"
LOCAL loODBC
loODBC = NEWOBJECT('iODBC')
LOCAL luReturn, lcString
luReturn = .F.
IF loODBC.IsDriverInstalled("VFP") AND (!loODBC.FindUserDSN(THIS.cProjectCode + " VSO3Views"))
*--
*-- Adding a VFP DSN example. Note that UNC pathing to the
*-- VFP DBC is acceptable for the THIS.cPathToDBC constant
*--
IF FILE(ADDBS(THIS.cPathToDBC) + DATABASE_NAME)
lcString = "SourceDB=" + ADDBS(THIS.cPathToDBC) + DATABASE_NAME + CHR(0) ;
+ "DSN=" + goApp.cProjectCode + " VSO3Views" + CHR(0) ;
+ "Description=" + goApp.cProjectCode + " VSO3Views" +CHR(0) ;
+ "SourceType=DBC" + CHR(0) ;
+ "BackgroundFetch=Yes" + CHR(0) ;
+ "Exclusive=No" + CHR(0) ;
+ "Collate=Machine" +CHR(0) ;
+ "SetNoCountOn=No"
luReturn = loODBC.CreateUserDSN("VFP", lcString)
ENDIF
ENDIF
loODBC.RELEASE()
[i-Level Change] Properties | Methods | Do:
LOCAL loINIFile, llReturn
loINIFile = CREATEOBJ("iINIFile", THIS.cINIFile)
IF loINIFile.GET("Data Settings", "Use Local Data", "YES", THIS.cINIFile) = "YES"
THIS.cPathToDBC = loINIFile.GET("DBC Locations - Local", "CDBK30", "DATA\", THIS.cINIFile)
ELSE
THIS.cPathToDBC = loINIFile.GET("DBC Locations - Remote", "CDBK30", "DATA\", THIS.cINIFile)
ENDIF
RELEASE loINIFile
THIS.SetupODBC()
llReturn = DODEFAULT()
*!* *!* luReturn = THIS.RemoveUserDSN(ODBC_MS_VFP, "C00 VSO3Views")
RETURN llReturn
>Hi Bhavbhuti
>Thanks for the quick reply.
>It took a bit more hand holding from a colleague but I finally got to configure a connection. You info really helped.
>Thanks again.