|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I've started my career as a VB programmer. I've created an Access database with some password set to it. Now I want to create a SystemDSN for that database ,that can be generated through VB code. This is the code that I've written for the same resulting some error.
Option Explicit Private Declare Function AccessConfigDatasource Lib "ODBCJT32.dll" (ByVal hwndParent As Long, ByVal fRequest As Long, ByVal lpszDriver As String, ByVal lpszAttributes As String) As Long Private Const ODBC_ADD_SYS_DSN = 4 Public Function CreateAccessDSN(DSNName As String, DatabaseFullPath As String) As Boolean Dim sAttributes As String If Dir(DatabaseFullPath) = "" Then Exit Function sAttributes = "DSN=" & DSNName & Chr(0) sAttributes = sAttributes & "DBQ=" & DatabaseFullPath & Chr(0) CreateAccessDSN = CreateDSN("Microsoft Access Driver(*.mdb)", sAttributes) End Function Public Function CreateDSN(Driver As String, Attributes As String) As Boolean CreateDSN = AccessConfigDatasource(0&, ODBC_ADD_SYS_DSN, Driver, Attributes) End Function |
|
#2
|
|||
|
|||
|
There is example code at www.mvps.org.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > How to create SystemDSN through VB Code |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|