|
-
Oct 30th, 2000, 04:21 AM
#1
Thread Starter
New Member
Can any body out there Show me the Code for Programmatically creating a DSN for Connecting to a text Database .
Thanks
Suman Perumbully
www.perumbully.itgo.com
-
Oct 30th, 2000, 04:54 AM
#2
Lively Member
You can create a DSN using RDO's rdoRegisterDataSource method.
If you need the code I can produce some for you.
-
Feb 18th, 2001, 06:15 PM
#3
Fanatic Member
Hi,
I know how to create a User DSN using rdoRegisterDataSource method. Do you know how to create the System DSN using code?
Regards,
TheBao
-
Feb 19th, 2001, 01:00 AM
#4
Lively Member
Hi,
The following API can be used to create a user, system DSN.
Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" (ByVal hwndParent As Long, ByVal fRequest As Long, ByVal lpszDriver As String, ByVal lpszAttributes As String) As Long
Regards,
Saran.
-
Feb 19th, 2001, 07:02 AM
#5
Lively Member
Here's fully functional routines for creating/deleting DSN
'Declarations Used to Generate DSN
Private Const ODBC_ADD_DSN = 1 ' Add data source
Private Const ODBC_CONFIG_DSN = 2 ' Configure (edit) data source
Private Const ODBC_REMOVE_DSN = 3 ' Remove data source
Private Const vbAPINull As Long = 0& ' NULL Pointer
Private 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 Sub CreateDSN(sDSN As String)
Dim nRet As Long
Dim sDriver As String
Dim sAttributes As String
sDriver = "Oracle73 Ver 2.5"
sAttributes = "Server=pressdb.world" & Chr$(0)
sAttributes = sAttributes & "DESCRIPTION=" & sDSN & Chr$(0)
sAttributes = sAttributes & "DSN=" & sDSN & Chr$(0)
sAttributes = sAttributes & "DATABASE=DB" & Chr$(0)
sAttributes = sAttributes & "UID=Vital" & Chr$(0)
sAttributes = sAttributes & "PWD=myPassword" & Chr$(0)
DBEngine.RegisterDatabase "kiki", "Oracle73 Ver 2.5", True, sAttributes
nRet = SQLConfigDataSource(vbAPINull, ODBC_REMOVE_DSN, sDriver, sAttributes)
End Sub
Public Sub DeleteDSN(sDSN As String)
Dim nRet As Long
Dim sDriver As String
Dim sAttributes As String
sDriver = "Oracle73 Ver 2.5"
sAttributes = sAttributes & "DSN=" & sDSN & Chr$(0)
nRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, sDriver, sAttributes)
End Sub
Have fun!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|