Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automating dBase System DSN creation

Status
Not open for further replies.

BKtechie

MIS
Mar 27, 2002
132
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top