Odbc

Discussions related to Visual Prolog
drspro2
VIP Member
Posts: 78
Joined: 28 Apr 2006 12:03

Odbc

Unread post by drspro2 » 30 Aug 2013 13:23

In Ms-windows I have added the Mysql odbc driver. Then in the data-sources of windows I can configure this driver's properties, I can give a username a password And I can give a database-name.

My question: is it possible to leave this field blank, so that (in my odbc prolog program ) I can select 1 of the available databases in this driver ?

If so, can I create a new database and select this one?



thankyou


R

User avatar
Thomas Linder Puls
VIP Member
Posts: 1622
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 30 Aug 2013 13:39

It depends on the driver. And the solution will become driver dependent.

You should use:

Code: Select all

predicates     driverConnect : (handle WindowHandle, string ConnStrIn, driverCompletion DriverCompletion) -> string ConnStrOut determ.
rather than connect.


In the simpleODBC example this code is used to connect to a specific Access database:

Code: Select all

        environment::getOSVersion(Vesion, _, _, _),         if Vesion > 5 then             ConStrIn = @"Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=..\odbc.mdb;"         else             ConStrIn = @"Driver={Microsoft Access Driver (*.mdb)};DBQ=..\odbc.mdb;"         end if,         Hwnd = gui_native::getDesktopWindow(),         ConStr = Connection:driverConnect(Hwnd, ConStrIn, odbc_native::sql_driver_complete),         !,         stdio::writef("ConStr = %\n", ConStr),
Regards Thomas Linder Puls
PDC

drspro2
VIP Member
Posts: 78
Joined: 28 Apr 2006 12:03

Unread post by drspro2 » 31 Aug 2013 11:14

Thankyou Thomas for the information.



In case of cgi wich I use, can I still use driver connect, and what could I use as the WindowHandle?
a sort of null-win ?


( driverConnect : (handle WindowHandle )





tx

User avatar
Thomas Linder Puls
VIP Member
Posts: 1622
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 31 Aug 2013 17:35

Yes, you can use a nullHandle.

The window handle is used as parent for dialogs (if you supply nullHandle the screen will become parent).

SQLDriverConnect (which is the underlying api function) will present dialogs for incomple connect strings. But for complete strings it will just connect.

To find the format of the connect string you invoke driverConnect with an empty string, and use the dialogs to create the connection. After that driverConnect returns the resulting connect string and then it is straight forward to see the format.
Regards Thomas Linder Puls
PDC

Post Reply