Comments (6)
Hi
It's been a few years since I did the TDS support in wxDatabase. I seem to remember TDS direct using FreeTDS working fine until an upgrade and then I resorted to accessing TDS via ODBC.
Please find below the content of the test.conf file I used last for testing. You'll notice that the only one uncommented is the TDS via ODBC
;SQLite3 via ODBC
;[ODBC]
;Connection=DRIVER=SQLite3 ODBC Driver;Database=C:\Documents and Settings\Andrew\My Documents\wxWidgets\samples\database\tests\test.sqlite;
;DbType=SQLITE
;Access via ODBC
;[ODBC]
;Connection=DRIVER={microsoft access driver (*.mdb)};dbq=C:\Documents and Settings\Andrew\My Documents\Downloads\NewDBtest\NewDBtest\db\db1.mdb;\nDSN=\nDbType=TDS\n");
;DbType=TDS
;SQLite3 direct
;[SQLite]
;database=C:\Users\Andrew Lawrance\Documents\wxWidgets\samples\database\tests\test.sqlite
;[PostgreSQL]
;library_location=C:\Program Files\PostgreSQL\8.3\bin
;server=127.0.0.1
;database=test_databaselayer
;user=user
;password=password
;port=5432
;[MySQL]
;library_location=C:\Program Files\MySQL\MySQL Server 5.1\bin
;server=127.0.0.1
;database=test_databaselayer
;user=test
;password=test
;TDS via ODBC
;[ODBC]
;Connection=DRIVER=SQL Server;SERVER=manyleaves\sqlexpress17;TRUSTED_CONNECTION=Yes;DATABASE=Test;
connection=DRIVER={SQL Server Native Client 11.0};MARS_CONNECTION=Yes;SERVER=manyleaves\sqlexpress17;TRUSTED_CONNECTION=Yes;DATABASE=test;DSN=
DbType=TDS
;TDS direct (see freetds.conf)
[TDS]
; can also setenv(FREETDS) instead of freetds=...
freetds=C:\wxDev\freetds-1.00.24\freetds.conf
server=manyleaves_sqlexpress
;server=127.0.0.1\sqlexpress17
database=test
;;version=7.3
;; user and password are necessary for trusted logins for version 7.2 and later
;;user=manyleaves\user
;;password=test
I hope this helps
Andrew
from wxdatabase.
Do I need to build a TDS-enabled library to use ODBC? Where should the wxUSE_DATABASE_ODBC preprocessor directive be uncommented?
In file C: \ Library \ wxDatabase \ src \ database \ odbc \ odbc_database.cpp this preprocessor directive is used for conditional compilation
from wxdatabase.
Here is the result of running the application with an ODBC connection string. In the file c: \ Library \ wxDatabase \ include \ wx \ database \ setup.h specified the preprocessor directive #define wxUSE_DATABASE_ODBC 1. But I don't see this file in the project structure in CodeBlocks
from wxdatabase.
It turned out to build the application using the library. But there are problems when passing the connection string from the config file.
Since I did a little bit with the implementation of the ODBC API, there are two ways to connect the databases. one using a DSN, the second is a direct connection to the database driver using a username and password. Is there a direct connection in the library using a wrapper over the SQLDriverConnect function
The dbType parameter is requested. what should i specify in the config file?
`#if wxUSE_DATABASE_ODBC
wxDatabase* wxDatabase::GetOdbcDatabase(wxConfigBase& config, wxString* err)
{
if (!config.HasGroup("ODBC"))
{
if (err) err->Append("/ODBC not defined");
return NULL;
}
config.SetPath("ODBC");
if (!wxOdbcDatabase::IsAvailable())
{
if (err) err->Append("ODBC database backend is not available");
return NULL;
}
wxString dbType;
if (!config.Read("DbType", &dbType))
{
if (err) err->Append("/ODBC/DbType not defined");
return NULL;
}
wxOdbcDatabase* pDatabase = new wxOdbcDatabase();
pDatabase->m_typeName = dbType;
wxString connection;
wxString user;
wxString password;
if (config.Read("Connection", &connection))
{
pDatabase->Open(connection);
}
else
{
wxString DSN;
if (!config.Read("DSN", &DSN, wxEmptyString))
{
if (err) err->Append("/ODBC/DSN not defined");
return NULL;
}
if (config.Read("user", &user, wxEmptyString))
{
config.Read("password", &password, wxEmptyString);
pDatabase->Open(DSN, user, password);
}
else
{
pDatabase->Open(DSN, wxEmptyString, wxEmptyString);
}
}
wxString libraryPath;
if (config.Read("library_path", &libraryPath))
{
pDatabase->m_libraryPath = libraryPath;
}
return pDatabase;
}
#endif`
from wxdatabase.
My apologies, the active string in the config I sent yesterday was for TDS direct and [ODBC] was partially commented out. For TDS via ODBC it should read as follows
;TDS via ODBC
[ODBC]
Connection=DRIVER={SQL Server Native Client 11.0};MARS_CONNECTION=Yes;SERVER=manyleaves\sqlexpress17;TRUSTED_CONNECTION=Yes;DATABASE=test;DSN=
DbType=TDS
NB: The DbType parameter is on a new line as above. This is what tells wxDatabase what type of ODBC Db to expect.
from wxdatabase.
Specified the following settings in the configuration file
[ODBC]
Connection = DRIVER = {SQL Server}; SERVER = 192.168.1.10; DATABASE = apacs24ms; UID = user; PWD = password;
DbType = TDS
The program connected to the MS SQL server, a table was created and displayed in the console
thanks
from wxdatabase.
Related Issues (20)
- CMake does not find MySQL Connector C 32-bit on 64-bit system HOT 5
- Redefinition of struct timespec (PostgreSQL vs mingw-w64) HOT 1
- Add Firebird backend HOT 3
- Possible memory leak in MySQL sample? HOT 6
- Update Readme to Reflect current status
- CMake can't find PostgreSQL headers on Ubuntu/Debian HOT 1
- Remove Exceptions HOT 2
- Online docs missing? HOT 2
- SQLite3 WHERE with Like does not work HOT 1
- wxDatabaseException does not derive from std::exception HOT 1
- Use Smart Pointers and avoid as much use of raw pointers as possible
- wxDatabase and WXwidget 3.0.5 HOT 26
- Update Bundled SQLite to 3.36.0 HOT 1
- Working with ODBC with a graphical interface. HOT 6
- Add Support for ODBC in CMake HOT 3
- add wxDatabase C'tors that doe not have Database in them HOT 2
- PGS: Fix Perfomance issue HOT 1
- PGS: Replace PQsetdbLogin with PQconnectdb HOT 1
- Implement ChangeDatabase for all backend HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wxdatabase.