|
-
Jun 16th, 2003, 12:48 AM
#1
Thread Starter
Fanatic Member
Adding DSN programmaticly - resolved
SQLConfigDataSource(0, ODBC_ADD_SYS_DSN, "MySQL ODBC 3.51 Driver", "DSN=MySQLTesting" & Chr(0)
& "SERVER=myServer.com.au" & Chr(0) & "DATABASE=testing" & Chr(0) &
"OPTION=" & (1 + 2 + 8 + 32 + 2048 + 16384) & Chr(0) & "UID=username" & Chr(0)
& "PORT=3306" & Chr(0)
& "DESCRIPTION=someDesc" & Chr(0))
It returns 1 ie succesful, yet i cant see it my ODBC datasources list (through administritive options)
help!?
Last edited by SkiNLaB; Jun 16th, 2003 at 11:36 PM.
-
Jun 16th, 2003, 01:44 AM
#2
Frenzied Member
Try this
VB Code:
Option Explicit
'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
'Code:
Public Sub CreateDSN(sDSN As String)
' * Comments : Create a DSN
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=Waty" & 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)
' * Comments : Delete a DSN
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
oh1mie/Vic

-
Jun 16th, 2003, 01:50 AM
#3
Thread Starter
Fanatic Member
whats dbengine? i am guessing its DAO, which i dont want to add to my project, I'd really like to get this API working.
thanks.
-
Jun 16th, 2003, 08:59 PM
#4
Thread Starter
Fanatic Member
-
Jun 16th, 2003, 11:36 PM
#5
Thread Starter
Fanatic Member
ugh, i ams teh dumb, i didnt have my constants at the right values. *sigh*
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
|