I am trying to connect to an ODBC data source that is properly setup and when i run the test connection it works. BUt when migrating my code from DAO to ADO the code sample below gives me an error: cannot connect to mysql server on localhot (10061)
Here is the sample code:
Dim conODBC As New ADODB.Connection
Dim rs As New ADODB.Recordset
conODBC.Open "Driver={MySQL ODBC 5.1 Driver};dsn=SomeDataSource;UID=SomeUserID;"
any ideas what could be causing this?
Related
I am trying to connect Excel to my Oracle database using VBA.
Sub dbConnect()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
strCon = "Driver={Microsoft ODBC for Oracle}; " & _
"CONNECTSTRING=(description=(address=(protocol=tcp)(host=mydb.domain.com)(port=1522))(connect_data=(sid=mydb))); uid=user; pwd=pw;"
con.Open (strCon)
End Sub
I get an error.
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I know from other questions and sources that the problem is most likely using the wrong version of the DSN.
However, I don't understand what I need to do to fix it.
My Windows is 64-bit, when I open the ODBC Data Source Administrator I see the following (among others):
Name: Excel Files, Platform: 64-bit, Driver: Microsoft Excel Driver
User DSN
Name: mydb, Platform: 32-bit, Driver: oracle in ORA121020_x86
under System DSN
What can I do to fix it? How do the connection string and the DNSs relate to each other? Should I change the version of one of the DNS and if yes how do I do that?
Edit:
The connection string is copied from the db connection in Oracel SQL Developer where I can access the db.
Ok I managed to fix it. My excel is 64 bit so in order to connect to the db, I had to create a System DNS for my connection that is also 64 bit. In order to do that, I had to go to the /Windows/system32 folder, choose the file odbcad32 and under system DNS add a new DNS with a 64 bit driver I had to download. Lets say I named that DNS abc
I then also changed the connection string that you can see in the above code to
strCon = "Data Source=abc;User=user;Password=pw"
According to this the connection string I used in the post above does not need a DNS, so I don't know why it didn't work, however after creating a new DNS as just described I switched to the new connection string that specifies a DNS.
And voila, after only several hours I was able to connect to my db.
Quick sidenote: As mentioned above, I edited the obcad32 file in /Windows/system32. This is the file for 64 bit DNS. There is a file with the exact same name in the folder /Windows/SysWOW64 that manages the 32 bit DNS, so if you have a similar problem as I had, pay attention to which file you edit.
Hello :) I've searched Stackoverflow and Google for a lot of hours and would like to have a clear answer to my problem, because I got a little bit confused. I want to link a table from my PostgreSQL database to my MS Access frontend using VBA. Therefore I'm using the ADO library and installed the 32 bit ODBC driver for PostgreSQL. It works great if I use a connection string with a defined DSN, code looks like this:
Set conn = New ADODB.Connection
Dim strConnect As String
strConnect = "DSN=PostgreSQL35W;Database=...;UID=...;PWD=..."
conn.Open
But the thing is that I dont wan't to use a connection string with DSN, because I dont want to mess around with these DSNs, esspecially not in a distributed environment. Therefore I would like to use a DSN-less connection string. But it seems like that the ADO library doesn't support DSN-less connection strings while using the ODBC driver for PostgreSQL. Is that true?
Here's the code I used for the DSN-less connection:
Set conn = New ADODB.Connection
Dim strConnect As String
strConnect = "ODBC;Driver={PostgreSQL Unicode};Server=...;Port=5432;Database=...;UID=...;PWD=..;TABLE=...
I know there are a lot of threads about that topic, but I couldn't get a clear answer for it. So thank you very much in advance!
In VB.net , EOF and BOD not working with ADODB recordset, even I added the right reference
DIM rsReqs as New ADODB.recordset
DIM cn as ADODB.connection
after open connection, with SQL Query I tryed to do this
rsReqs.open(StrSQL,cn)
Do until rsreqs.EOF
....
....
Thank's for your help
You can't use that libraries on vb.net, find the libraries based on your database server. Find more about how to connect your database (like mysql or access) with vb.net by googling.
Helllo!
I'm an MS Access-beginner. After an upgrade from Access2003 to Access2010 I am changing the database connection of our MS Access-Application from ODBCDirect (not supported anymore) to ADODB.
After (hopefully) successfully establishing a DB connection over an ADODB.Connection object I am initializing an ADODB.Command object:
Dim qdfWork As ADODB.Command
...
Set qdfWork = New ADODB.Command
Set qdfWork.ActiveConnection = CurrentProject.Connection
qdfWork.CommandText = "[dbo].[storedProcedureName]"
qdfWork.CommandType = adCmdStoredProc
qdfWork.Parameters.Refresh 'HERE THE ERROR-MESSAGE OCCURS
...
There is a stored procedure with the exactly same name "[dbo].[storedProcedureName]" stored on the server, but I still get the error-message:
"the microsoft access database engine cannot find the input table or query 'dbo'. Make sure it exists and that its name is spelled correctly."
If I don't write "[dbo]" in the CommandText I still get the same message, telling that "[storedProcedureName]" can't be found.
Here is my ADODB.Connection.connectionString:
"Driver={Microsoft Access Driver (*.mdb)};Dbq=\\folder1\folder2\User1\Database.mdb; Uid=Admin;Pwd=password;"
The connection via this connectionString works fine I think, I don't get any error-messages when connecting to the DB.
I checked that CurrentProject.Connection is really the connection I need.
I don't understand why my Application can't find this stored procedure although it is stored on the server.
Thanks for reading
I've got the following code and I'm trying to establish a connection to a data base. I have MSSQL 2005 as the database and trying to connect though ODBC connection.
Importantly I'm trying to use 'Windows authentication' instead of 'SQL authentication' to login to the database. (Note that SQL auth is NOT an option for me!)
<%
Dim Conn
Set Conn = CreateObject("ADODB.Connection")
Dim ConnectionString
Conn.ConnectionString = "Server= CLMSAWN002; Database= mohan_db; Integrated Security=True;"
Conn.Open ConnectionString
Conn.CommandTimeout=120
Sub CloseConn
Conn.Close
Set Conn = Nothing
End Sub
%>
In the live environment I get the following error.
Microsoft OLE DB Service Components error '80040e21'
Multiple-step OLE DB operation generated errors. Check each OLE DB
status value, if available. No work was done.
/CustomerMarketing/_db.asp, line 10
Can you help me understand what cause this and a possible solution?