This will create an ODBC DSN for an Access database.
Public Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" _
(ByVal hwndParent As Long, ByVal fRequest As Long, _
ByVal lpszDriver As String, ByVal lpszAttributes As String)
As Long
Public Function CreateAccessDSN(DSNName As String, DatabaseFullPath As
String) _
As Boolean
Dim sAttributes As String
sAttributes = "DSN=" & DSNName
sAttributes = sAttributes & "DBQ=" & DatabaseFullPath
CreateAccessDSN = CreateDSN("Microsoft Access Driver (*.mdb)",
sAttributes)
End Function
Public Function CreateDSN(Driver As String, Attributes As String) As Boolean
CreateDSN = SQLConfigDataSource(0&, 1, Driver, Attributes)
End Function
Public Sub Create()
Dim blnRetVal As Boolean
blnRetVal = CreateAccessDSN("DSNName", "C:\myDatabase.mdb")
End Sub
Rick Rose
-------Original Message-------
From: [EMAIL PROTECTED]
Date: 09/27/04 11:14:05
To: [EMAIL PROTECTED]
Subject: [vbhelp] Creating an ODBC Source programatically
Dear Group:
I've faced this problem several times already, and i've never found a
"civilized" solution...
I have to create an ODBC Source programatically. I've seen several programs
do this, they create their own ODBC sources instead of making you create
them manually, but i've never found the way to do it.
I seriously want to believe there's a better way than manually writing
Hard-coded values to the Registry (inside HKLM\Software\ODBC\ODBC.INI).
Does anyone know how to go around doing this?
I imagine this will be different for every driver. The one i'm most
interested in is IBM "Client Access" (or "iSeries Access"), but any driver
will do, it will point me in the right direction at least.
Thanks a lot in advance
Daniel Magliola
Cimatic SRL
+5411 4787 5311
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/k7folB/TM
--------------------------------------------------------------------~->
'// =======================================================
Rules : http://ReliableAnswers.com/List/Rules.asp
Home : http://groups.yahoo.com/group/vbHelp/
=======================================================
Post : [EMAIL PROTECTED]
Join : [EMAIL PROTECTED]
Leave : [EMAIL PROTECTED]
'// =======================================================
Yahoo! Groups Links
.
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/k7folB/TM
--------------------------------------------------------------------~->
'// =======================================================
Rules : http://ReliableAnswers.com/List/Rules.asp
Home : http://groups.yahoo.com/group/vbHelp/
=======================================================
Post : [EMAIL PROTECTED]
Join : [EMAIL PROTECTED]
Leave : [EMAIL PROTECTED]
'// =======================================================
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/vbhelp/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/