Status & Roadmap
Authors & License
Funding Ultimate++
Search on this site
Search in forums

SourceForge.net Logo
Home » U++ Library support » U++ SQL » How to connect to ODBC??
How to connect to ODBC?? [message #47798] Wed, 29 March 2017 09:42 Go to next message
NilaT is currently offline  NilaT
Messages: 70
Registered: November 2011
Location: Austria
Hello everyone, I have a new question for you Wink

I have a mdb Database and I want to connect to it with U++ using ODBC.

So, I added the data source to ODBC32 Bit:
For User-DSN and System-DSN.
Name is anything, Platform is 32 Bit, Driver is Driver do Microsoft Access (*.mdb) and also tried Microsoft Access Driver (*.mdb)

Then, in my program, I use the following code:
(be aware that I use 2010 sources):
ODBCSession session;
  String cs = Format("DRIVER=%s;SERVER=(local);Trusted_Connection=yes;", "something"); // DRIVER is the same name as in ODBC data source, also tried {SQL Server}
    Cout() << session.GetErrorStatement() << "\n";

With DRIVER = "something" I get the error: [Microsoft][ODBC Driver Manager]The datasource was not found, no standard driver... (translated to english, original error message is german so may it's not 100% the right message)

With DRIVER = {SQL Server} I get: [Microsoft][ODBC SQL Server Driver][Shared Memory]SQL Server does not exist or connection refused
and [Microsoft][ODBC SQL Server Driver][Shared Memory]ConnectionOpen (Connect())

I also tried disabling the firewall, with no success.

Am I missing something?
Please help me.
Re: How to connect to ODBC?? [message #47799 is a reply to message #47798] Wed, 29 March 2017 10:14 Go to previous message
NilaT is currently offline  NilaT
Messages: 70
Registered: November 2011
Location: Austria
Nevermind, just found it on my own...
There is no need for an ODBC Data connection, and no need for a firewall rule.

I simply changed my connection string to the following:
connectionString = "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\\path\\database.mdb;Uid=;Pwd=;";

according to:
https://www.connectionstrings.com/access/#net-framework-data -provider-for-odbc

and it works.

[Updated on: Wed, 29 March 2017 10:15]

Report message to a moderator

Previous Topic: How can .sch express a many-to-many relationship ?
Next Topic: MSSQL connection cause memory leak
Goto Forum:

Current Time: Wed Jul 24 16:45:56 CEST 2024

Total time taken to generate the page: 0.01841 seconds