-
Jul 11th, 2018, 01:29 AM
#1
Thread Starter
Addicted Member
Dsn odbc dao vb6
I need some advice on opening a MySql database DSN in VB6 with ODBC and DAO.
The code I use fails, and I do not know why.
Dim wsODBC As Workspace
Set wsODBC = DBEngine.CreateWorkspace("ODBCWorkspace", "admin", "", dbUseODBC)
Workspaces.Append wsODBC
Dim Conn As Connection
Set Conn = wsODBC.OpenConnection("Conn1", , , "ODBC;DSN=ibsmsbloem;") - this line gives an error OBDC call failed.
Dim rs As Recordset
Set rs = Conn.OpenRecordset("accountterms", dbOpenSnapshot)
Is there some checklist through which I may work to check that I have done everything right or some examples.
Thanks
-
Jul 11th, 2018, 02:25 AM
#2
Re: Dsn odbc dao vb6
Try
Code:
Dim Conn As Connection
Set Conn = wsODBC.OpenConnection("IBSMSbloem")
see: https://msdn.microsoft.com/de-de/lib.../ff196074.aspx
If you specify a registered ODBC data source name (DSN) in the connect argument, then the name argument can be any valid string, and will also provide the Name property for the Connection object. If a valid DSN is not included in the connect argument, then name must refer to a valid ODBC DSN, which will also be the Name property.
One System to rule them all, One IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
For health reasons i try to avoid reading unformatted Code
-
Jul 11th, 2018, 05:26 AM
#3
Re: Dsn odbc dao vb6
Hi Peekay,
it's been a while since I used DAO, but I'll have go....
Code:
Private Sub Command1_Click()
Dim ws As Workspace
Dim cn As Connection
Dim qd As QueryDef
Dim rs As Recordset
Set ws = CreateWorkspace("SQL_Server_ODBC", "", "", dbUseODBC)
Set cn = ws.OpenConnection("SQL_Server_Conn", dbDriverComplete, False, "ODBC;DSN=TestDaten;UID=USERNAME;")
Set qd = cn.CreateQueryDef("")
qd.SQL = "SELECT * FROM YourTable"
qd.ODBCTimeout = 0
Set rs = qd.OpenRecordset(dbOpenForwardOnly)
MsgBox "Name: " & rs!dsName
rs.Close
Set rs = Nothing
Set qd = Nothing
cn.Close
Set cn = Nothing
Set ws = Nothing
End Sub
regards
Chris
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
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
|