Hello all,
I've been trying to automate the creation of SYS DSN's in some recent software. To do so I've been calling SQLConfigDataSource from ODBCCP32.DLL. Are there any tips or tricks to get it to work with dBase 5 files? I'd rather not train these guys how to set up DSN's. Here is the code I have so far:
Public Function Create_EzRA_DSN(dpath$, year$) As Boolean
'dpath$ is the main directory for data
'year$ is the achieve sub directory where to get data
Dim dsn_name$
Dim data_sc$
Dim Driver$, Attributes$
data_sc$ = dpath$ & IIf(year$ = "", "", "\" & year$)
Driver$ = "Driver={Microsoft dBase Driver(*.dbf)}" & Chr(0)
Attributes$ = "DNS=EzRA_" & year$ & Chr(0)
Attributes$ = Attributes & "DEFAULTDIR=" & data_sc$ & Chr(0)
Attributes$ = Attributes & "Deleted=0" & Chr(0)
Attributes$ = Attributes & "FIL=dBase 5" & Chr(0)
Attributes$ = Attributes & "CollatingSequence = ASCII" _
& Chr(0)
Attributes$ = Attributes & "DBQ=" & data_sc$ & Chr(0)
Attributes$ = Attributes & "Driver={Microsoft dBase" & _
" Driver (*.dbf)}" & Chr(0)
Attributes$ = Attributes & "DriverId = 533" & Chr(0)
Attributes$ = Attributes & "FIL=dBase 5.0" & Chr(0)
Attributes$ = Attributes & "MaxBufferSize = 2048" & Chr(0)
Attributes$ = Attributes & "MaxScanRows = 8" & Chr(0)
Attributes$ = Attributes & "PageTimeout = 5" & Chr(0)
Attributes$ = Attributes & "SafeTransactions = 0" & Chr(0)
Attributes$ = Attributes & "Statistics = 0" & Chr(0)
Attributes$ = Attributes & "Threads = 3" & Chr(0)
Attributes$ = Attributes & "UserCommitSync = Yes" & Chr(0)
Create_EzRA_DSN = IIf(SQLConfigDataSource(0, _
ODBC_ADD_SYS_DSN, Driver$, Attributes$) = 1, True, False)
End Function
Thanks in advance,
BKtechie
I've been trying to automate the creation of SYS DSN's in some recent software. To do so I've been calling SQLConfigDataSource from ODBCCP32.DLL. Are there any tips or tricks to get it to work with dBase 5 files? I'd rather not train these guys how to set up DSN's. Here is the code I have so far:
Public Function Create_EzRA_DSN(dpath$, year$) As Boolean
'dpath$ is the main directory for data
'year$ is the achieve sub directory where to get data
Dim dsn_name$
Dim data_sc$
Dim Driver$, Attributes$
data_sc$ = dpath$ & IIf(year$ = "", "", "\" & year$)
Driver$ = "Driver={Microsoft dBase Driver(*.dbf)}" & Chr(0)
Attributes$ = "DNS=EzRA_" & year$ & Chr(0)
Attributes$ = Attributes & "DEFAULTDIR=" & data_sc$ & Chr(0)
Attributes$ = Attributes & "Deleted=0" & Chr(0)
Attributes$ = Attributes & "FIL=dBase 5" & Chr(0)
Attributes$ = Attributes & "CollatingSequence = ASCII" _
& Chr(0)
Attributes$ = Attributes & "DBQ=" & data_sc$ & Chr(0)
Attributes$ = Attributes & "Driver={Microsoft dBase" & _
" Driver (*.dbf)}" & Chr(0)
Attributes$ = Attributes & "DriverId = 533" & Chr(0)
Attributes$ = Attributes & "FIL=dBase 5.0" & Chr(0)
Attributes$ = Attributes & "MaxBufferSize = 2048" & Chr(0)
Attributes$ = Attributes & "MaxScanRows = 8" & Chr(0)
Attributes$ = Attributes & "PageTimeout = 5" & Chr(0)
Attributes$ = Attributes & "SafeTransactions = 0" & Chr(0)
Attributes$ = Attributes & "Statistics = 0" & Chr(0)
Attributes$ = Attributes & "Threads = 3" & Chr(0)
Attributes$ = Attributes & "UserCommitSync = Yes" & Chr(0)
Create_EzRA_DSN = IIf(SQLConfigDataSource(0, _
ODBC_ADD_SYS_DSN, Driver$, Attributes$) = 1, True, False)
End Function
Thanks in advance,
BKtechie