简体   繁体   中英

C++ Database API's - DTL

I'm looking for a C++ API that is able to connect to different types of databases all in one; mainly MySQL, oracle and SQL Server and I believe I have found one with "DTL" ( http://dtemplatelib.sourceforge.net/ )

However, I'm struggling to connect my database on localhost. Has anyone used this before and could shed some more light on it other than what their site does with

DBConnection::GetDefaultConnection().Connect("UID=example;PWD=example;DSN=example;");

though I guess what to put in uid and pwd, I'm not sure what it's expecting in 'dsn', are there any REAL examples or have you guys used it before and could help.

This is an ODBC library, so DSN is the ODBC data source name. On Windows, these can be configured under Administrative Tools->Data Sources.

As @Dark Falcon said, the "DSN" refers to an "ODBC data source". What you get is an extra level of indirection like this:

在此处输入图像描述

On Windows, you normally create the ODBC data source with the "Data Sources (ODBC)" control panel, which is normally in the "Administrative Tools".

In any case, this separates the configuration/deployment "stuff" from the code. For example, if you want to use your code with a test database during development, then with the "live" database when you deploy it, you can do that without making any changes to your code, and even without changing the connection string. Instead, you change the data source to refer to production server instead of the test server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM