ODBC connections....

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

ODBC connections....

Marc Giezen
We are having a hard time trying to connect to a MSSQL and a MySQL
Database... without using the ODBC manager.... so trying to connect
directly from within Dolfin... (building the connect string and
execute it)

is there enybody out there that has any experiance or some kind of
sample for this..

Many thinks in advance

Marc Giezen
www.insurancecity.de


Reply | Threaded
Open this post in threaded view
|

Re: ODBC connections....

John Aspinall
Marc,

> We are having a hard time trying to connect to a MSSQL and a MySQL
> Database... without using the ODBC manager.... so trying to connect
> directly from within Dolfin... (building the connect string and
> execute it)

As far as I can see, Dolphin doesn't support DSNless connections. Look at
DBConnection>>connectString: - this deconstructs a connection string into
DSN, user ID and password. DBConnection>>connectString then reconstructs the
connection string from these constituent parts.

To setup a DSNless connection, you need to be able to specify the whole
connection string yourself. A quick way to do this is to modify
DBConnection>>open, changing the line:

    szConnStrIn: self connectString

for:

    szConnStrIn: self dsn

...and then setting a DSNless connection string directly into the dsn
instance variable. The following works for Access:

c := DBConnection new.
c dsn: 'DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\temp\test.mdb'.
c open.
c tables inspect.
c close

I don't have MSSQL to test against, however when I tried the equivalent with
MySQL:

c := DBConnection new.
c dsn: 'DRIVER=MySQL;SERVER=localhost;DATABASE=Test;UID=root'.
c open.
c tables inspect.
c close

...I was prompted by a MySQL ODBC setup dialog, populated with the server
and database info from the connection string, but demanding that I give the
connection a DSN (the DSN I enter is not added to the ODBC manager,
however). I eventually overcame this by changing another line in
DBConnection>>open. Change:

    fDriverCompletion: SQLDriverComplete.

to:

    fDriverCompletion: SQLDriverNoPrompt.

Looking at the MSDN documentation for SQLDriverConnect, I'm not entirely
sure that MySQL's behaviour under SQLDriverComplete is correct (it shouldn't
prompt with a dialog unless it has insufficient information to connect).
However, I think a prompt-less version of open would be useful anyway -
perhaps this could be added in a subsequent release?

Best regards,

John Aspinall
Solutions Software


Reply | Threaded
Open this post in threaded view
|

Re: ODBC connections....

Don Rylander
Another option is to generate classes for ADO and use them.  I know that allows
you to connect directly to Access .mdb files or SQLServer; I don't know whether
it works with MySQL.  Microsoft's Data Access Components are available for
download at http://www.microsoft.com/data/download.htm.

Don


Reply | Threaded
Open this post in threaded view
|

Re: ODBC connections....

Andy Bower
In reply to this post by John Aspinall
Marc, John,

This has now been recorded as enhancement #237 and should appear in a
forthcoming release.

Best Regards,

Andy Bower
Dolphin Support
http://www.object-arts.com

---
Visit the Dolphin Smalltalk WikiWeb
http://www.object-arts.com/wiki/html/Dolphin/FrontPage.htm
---

"John Aspinall" <[hidden email]> wrote in message
news:P69P6.25178$[hidden email]...

> Marc,
>
> > We are having a hard time trying to connect to a MSSQL and a MySQL
> > Database... without using the ODBC manager.... so trying to connect
> > directly from within Dolfin... (building the connect string and
> > execute it)
>
> As far as I can see, Dolphin doesn't support DSNless connections. Look at
> DBConnection>>connectString: - this deconstructs a connection string into
> DSN, user ID and password. DBConnection>>connectString then reconstructs
the

> connection string from these constituent parts.
>
> To setup a DSNless connection, you need to be able to specify the whole
> connection string yourself. A quick way to do this is to modify
> DBConnection>>open, changing the line:
>
>     szConnStrIn: self connectString
>
> for:
>
>     szConnStrIn: self dsn
>
> ...and then setting a DSNless connection string directly into the dsn
> instance variable. The following works for Access:
>
> c := DBConnection new.
> c dsn: 'DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\temp\test.mdb'.
> c open.
> c tables inspect.
> c close
>
> I don't have MSSQL to test against, however when I tried the equivalent
with

> MySQL:
>
> c := DBConnection new.
> c dsn: 'DRIVER=MySQL;SERVER=localhost;DATABASE=Test;UID=root'.
> c open.
> c tables inspect.
> c close
>
> ...I was prompted by a MySQL ODBC setup dialog, populated with the server
> and database info from the connection string, but demanding that I give
the

> connection a DSN (the DSN I enter is not added to the ODBC manager,
> however). I eventually overcame this by changing another line in
> DBConnection>>open. Change:
>
>     fDriverCompletion: SQLDriverComplete.
>
> to:
>
>     fDriverCompletion: SQLDriverNoPrompt.
>
> Looking at the MSDN documentation for SQLDriverConnect, I'm not entirely
> sure that MySQL's behaviour under SQLDriverComplete is correct (it
shouldn't

> prompt with a dialog unless it has insufficient information to connect).
> However, I think a prompt-less version of open would be useful anyway -
> perhaps this could be added in a subsequent release?
>
> Best regards,
>
> John Aspinall
> Solutions Software
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>