Problem sending datas by Excel-VBA to PostgressSQL: [ODBC driver manager] data source name not found and no default driver specified - excel

I need help with a task.
I have a VBA code at Excel to send some datas for PostgressSQL.
These days I reinstalled my Excel, but now, when I try to send the data the VBA presents the message below and the data is not include in my database:
"[ODBC driver manager] data source name not found and no default driver specified"
The debug highlight that the problem is in Conexao.Open. Below is part of the code with this:
Sub Conectar_BD()
Set Conexao = New ADODB.Connection
Conexao.ConnectionString = "DRIVER={PostgreSQL ANSI(x64)}; SERVER=localhost; DATABASE=yyyy; UID=marcel; PASSWORD=xxx;"
Conexao.Open
End Sub
Looking for some answers I found the explanation that I have to install the driver, but I´m not sure about how I could do that.
However, researching more I discovered a tutorial teaching how to connect the driver by admnistrative tool in the panel of control of windows called Datasource ODBC.
Following the instructions, when I added PostgreSQL ANSI(x64), that is there and put the credentials of my database, the conecction was sucessfully but the excel continue to present the same message.
Anyway, I don´t know how to fix this problem yet.
Anyone can help me?

Related

VBA connection via ODBC (3.0.6) / ADODB to MariaDB 10.3.8

I downloaded and installed the MariaDB ODBC Driver 3.0.6 and installed it on my computer. Then I wrote a small piece of VBA in EXCEL 2016 which connects to the DB, which seems to work, and tries to query some entries.
Here is where the problems start:
The recordset allways returns a RecordCount of -1
EXCEL crashes when executing any rs cursor command (MoveLast etc.), but that is probably because I don't have any recors
If I use CursorLocation adUseClient, as suggested in many posts I could find, instead of asUseServer VBA throws the following error: Runtime error '-2147467259 (80004005)' ... returned Status E_FAIL
Edit:
The issue was officialy fixed in the following versions: 3.0.7, 2.0.19, 3.1.0
Link to Issue
I found the Solution: use MariaDB ODBC Driver 3.0.5 instead of 3.0.6. Then everything works fine with the adUseClient Cursor...
Perhaps it saves someone a little time... :-)

Receiving Market Data into Excel

My summer project is developing an algorithmic trader that receives market data and trades based off indicators. I pull data from a company called Interactive Brokers using their TWS(Trader workshop station). I have downloaded their Excel API which uses DDE, but cannot get the Excel spreadsheet to properly connect with TWS.
In my excel spreadsheet, I wrote this command into a random cell. I've replaced 'sample123' with my TWS username It is suppose to evaluate to 0 before I make other adjustments but it evaluates to #REF!:
=Ssample123|tik!'id1?req?EUR_CASH_IDEALPRO_USD_~/'
Image of error received
Another issue with the error is it deletes two characters off my username and I am unsure of why.
Ex: username -> Sample123
Outcome -> Sample1
Any suggestions would be greatly appreciated! Thank you and have a nice day.
'sample123' in the example formula is the username that was used to login to TWS. It has to be replaced in your formulas with the actual username you used to login to TWS.
Also, to use the older legacy TWS DDE API you have to be running 32 bit TWS and have the setting "Enable DDE" checked in TWS Global Configuration.
Issues causing the #REF error
There is a newer 'DDE Socket Bridge' TWS API also available in the Latest version of the API which has additional functionality and is compatible with the 64 bit version of TWS.
DDE SocketBridge API
I've had the same problem. Just put twsserver instead

vb.net Cannot update. Getting error "Database or object is read-only." when just trying to READ from excel file

I'm more than willing to accept other suggestions on ways to accomplish what I want to do. I am trying to read some lines from an excel spreadsheet that the user uploads to my application. The web server where this will eventually reside does not have excel installed on it, which makes referencing things like Microsoft.Office.Interop.Excel.dll in my project impossible. So I've been looking for ways to read the excel file so that will work with this situation. The best way I've found so far is to use Microsoft.Jet.OLEDB.4.0 to connect to the excel file like a datasource. Here is a small snippet of I've put together so far:
Dim excelFileName As String = "C:\\Import\\K12Mercury.xlsx"
Dim conn As New OleDb.OleDbConnection(String.Format("provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & excelFileName & "; Extended Properties='Excel 8.0;HDR=YES;'"))
conn.Open()
The program fails on the conn.Open() line with the error:
cannot update. database or object is read-only
I don't know why this is happening or if this is even the best route to use to be able to read from an excel file in an environment where excel is not installed. Will someone please help me? Thanks in advance.

ODBC Driver has become erratic when making connection and processing SQL query

I have an Excel Macro Workbook (binary extension) that suddenly has developed 2 issues occasionally (sometimes it runs fine).
#1 Issue - Occasionally there is an error on Line 5
It appears the connection does not open. We get the error:
Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x7f8 Thread 0x1174 DBC
#2 Issue - Occasionally there is an error on Line 7
It appears the SQL can not run. It indicates the Worksheet tab can not be found even though it does exist. Note for this error we have no issue with Line 5 (Open Connection). The error that displays is:
[Microsoft][ODBC Excel Driver] The microsoft jet database engine could not find the object 'Worksheet Name'. Make sure the object exists...
For Issue #2 once we close the error dialog box and THE MACRO GETS DELETED !!!
Notes
The code module has not been changed in years Some days we get no errors/issues
This issue occurs for multiple Excel workbooks run by multiple people that run different VBA code blocks. However 1 of the code blocks is the same across all these macros which is the code snippet above.
The source data has not changed in years in terms of formatting or volume.
All these workbooks are on a Network server.
We are on Windows7/Excel 2010/ODBC Excel Driver (xls xlsx xlsm xlsb)
14.00.7180.5000
Code Snippet
1-Set adoConn = Nothing
2-Set adoRS = Nothing
3-Application.EnableCancelKey = xldisabled
4-strConn = "Driver={Microsoft Excel Driver (*.xls,*.xlsx,*.xlsm,*.xlsb)};DriverId=1046;Dbq=" & strFileName & ";IMEX=1;"
5-Set adoConn = New ADODB.Connection: adoConn.Open strConn
6-Application.EnableCancelKey = xlInterrupt
7-Set adoRS = New ADODB.Recordset:adoRS.Open Source:=strSQL,ActiveConnection:=adoConn
I'm curious as to why you're using ODBC to connect Excel to another Excel file, as opposed as to linking the data directly.
Intermittent connection problems point to a network issue. I would suggest removing and re-creating the ODBC connection, but I'd first want to confirm the value of strFileName as referred to in the connection string. Is it an actual server on your internal network, or an external source? (ie, is it a UNC path?)
An intermittent Unable to open registry key error likely sounds worse than it is; when having connection problems, Windows & Excel will easily get confused as to what the real problem is.
It sounds like your setup has been in place, possibly un-maintained, for a long time. When is the last time the client and server were rebooted? (Should be nightly.) Defrag, disk cleanup, etc?
As for the issue of the macro "getting deleted" when you close an error dialog, I'd need to see proof of that. I think you're misunderstanding something, unless you're re-writing the macro from scratch each time this happens..

VBA odbc connection accessing a single library only

I have successfully connected to an as400 server. But whenever i execute an sql statement
select * from nosd0
It doesn't work, because nosd0 is in lib1/fil1(nosd0)
it gives an error saying nosd0 is not in lib2.
When I execute the query on STRSQL on as400 it works fine.
I tried creating an alias and it's malfunctioning. Please I really need some help on this one
Alias is working, I am accessing the wrong file.
Ok I figured out the problem, this will also help all those who wants to connect to their AS400 iSeries using VBA. ;)
My problem above is that when I try my Query on the box, it accesses lib1/nosd0, and in VBA, I was trying to get lib2/fil1(nosd0) which is a description of the table nosdo itself. The simple solution is to query
select * from lib1.nosd0
More on that when connecting to an AS400 iSeries using ODBC, there is a parameter called DBQ
Connection String Parameters
My final connection string would be.
ConnectString = "Driver={ISeries Access ODBC Driver};System=" & DCServer(I) & ";Uid=--;Pwd=--;NAM=0;DBQ=lib1,*ALL;"

Resources