Git Product home page Git Product logo

Comments (6)

manyleaves avatar manyleaves commented on July 28, 2024

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.

Melandr avatar Melandr commented on July 28, 2024

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
1

from wxdatabase.

Melandr avatar Melandr commented on July 28, 2024

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
2

from wxdatabase.

Melandr avatar Melandr commented on July 28, 2024

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
3
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.

manyleaves avatar manyleaves commented on July 28, 2024

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.

Melandr avatar Melandr commented on July 28, 2024

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
test

thanks

from wxdatabase.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.