Database open with a Connection String
Database open with a Connection String
Hi,
it would be nice if PB could open a Database with a ConnectionString like this:
OpenDatabase(0,"Driver=MySQL ODBC 3.51 Driver;Server=192.168.0.1;Host=localhost;Network=DBMSSOCN;Database=Cars;User=root;Password=","","")
So you only need to install the ODBC-Driver but not specify the connection.
it would be nice if PB could open a Database with a ConnectionString like this:
OpenDatabase(0,"Driver=MySQL ODBC 3.51 Driver;Server=192.168.0.1;Host=localhost;Network=DBMSSOCN;Database=Cars;User=root;Password=","","")
So you only need to install the ODBC-Driver but not specify the connection.
Re: Database open with a Connection String
We still can't use dsn-less connection, right? I know there are some tricks on the forum.
It would be really nice if we could give connection string instead of dsn name.
It would be really nice if we could give connection string instead of dsn name.
-= endo (registered user of purebasic since 98) =-
Re: Database open with a Connection String
Yes - it's a good idea.
This could offers much more control on the connection.
For those who don't knows (very handy) :
http://www.connectionstrings.com/
This could offers much more control on the connection.
For those who don't knows (very handy) :
http://www.connectionstrings.com/
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Re: Database open with a Connection String
I'm totally new to Purebasic.
As no-one posted an answer I suppose this isn't possible?
I personally only need to specificy the databasename on an existing DSN, so f.e.:
Other programming tools can do this easily, so this must/should be possible in Purebasic?
As no-one posted an answer I suppose this isn't possible?
I personally only need to specificy the databasename on an existing DSN, so f.e.:
Code: Select all
"DSN=<dsn_name>;DB=<database_name>;UID=<user>;PWD=<password>"
Re: Database open with a Connection String
Hi, unfortunately DSN-less conntection is still not possible in Purebasic. There are some workarounds like creating/deleting a DSN programatically using odbcconf.exe which is the easiest way (on Windows)
Or use a dsn to connect to your database server and change the db using USE <dbname>.
Or use a dsn to connect to your database server and change the db using USE <dbname>.
-= endo (registered user of purebasic since 98) =-
Re: Database open with a Connection String
Creating a separate DSN for each databasename isn't an option, as the number of databasenames can be long and dynamic. I hope that this feature will be introduced soon then, as this makes it difficult/cumbersome to create serious business applications with PureBasic ....endo wrote:Hi, unfortunately DSN-less conntection is still not possible in Purebasic. There are some workarounds like creating/deleting a DSN programatically using odbcconf.exe which is the easiest way (on Windows)
Or use a dsn to connect to your database server and change the db using USE <dbname>.
Re: Database open with a Connection String
Yes I definitely agree with you.
My way is just a workaround. But it is not necessary to create DSN for each db, you can create one when your application starts (by calling the odbcconf.exe dos command) and delete when your app quits. Or just create it once when your application installed, then update it for different databases when it starts and remove it during uninstall.
My way is just a workaround. But it is not necessary to create DSN for each db, you can create one when your application starts (by calling the odbcconf.exe dos command) and delete when your app quits. Or just create it once when your application installed, then update it for different databases when it starts and remove it during uninstall.
-= endo (registered user of purebasic since 98) =-
Re: Database open with a Connection String
That could work, but unfortunately this is what Microsoft tells me:endo wrote:Yes I definitely agree with you.
My way is just a workaround. But it is not necessary to create DSN for each db, you can create one when your application starts (by calling the odbcconf.exe dos command) and delete when your app quits. Or just create it once when your application installed, then update it for different databases when it starts and remove it during uninstall.
http://msdn.microsoft.com/en-us/library ... S.85).aspxODBCCONF.exe will be removed in a future version of Windows Data Access Components. Avoid using this feature, and plan to modify applications that currently use this feature.
My strategy is not to use components that are or will be deprecated.
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: Database open with a Connection String
You can create / delete ODBC DSN on the fly without any external tool.
An example : http://www.purebasic.fr/english/viewtop ... 12&t=16474
An example : http://www.purebasic.fr/english/viewtop ... 12&t=16474
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Re: Database open with a Connection String
Nicely done!gnozal wrote:You can create / delete ODBC DSN on the fly without any external tool.
An example : http://www.purebasic.fr/english/viewtop ... 12&t=16474
However I prefer not to use work-arounds like that (modifying registry fe); I still hope that Fred will just add an extra databasename argument to the OpenDatabase function. If he's that smart as many are telling then that should be done in 1 minute ....

Re: Database open with a Connection String
Hi,
I think, this is the best method to use DSN.
In this case I had an additional Idee you can see here http://www.purebasic.fr/english/viewtop ... =3&t=41182
EDIT: It is not the best way, but you can connect to the most Databases. Ok, Oracel and so on...
I think, this is the best method to use DSN.
In this case I had an additional Idee you can see here http://www.purebasic.fr/english/viewtop ... =3&t=41182
EDIT: It is not the best way, but you can connect to the most Databases. Ok, Oracel and so on...
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Re: Database open with a Connection String
Thanks for the link, it is VERY handy!Flype wrote:Yes - it's a good idea.
This could offers much more control on the connection.
For those who don't knows (very handy) :
http://www.connectionstrings.com/

https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system