composing connection string for ODBC

Bob Rasmussen brasmussen at earthlink.net
Thu Oct 24 21:24:01 EDT 2002


> Trying to make my ODBC connection strings dynamically modifiable, but I have a
> problem.
>
> Here's the code
>
>     put quote & the text of button btnDbType & quote into DbType
>     put quote & the text of field fdDsn & quote into Dsn
>     put quote & the text of field fdUsername & quote into Username
>     put quote & the cpPassword of field fdDsn & quote into thePassword
>     answer DbType,Dsn,Username,thePassword
>     get revdb_connect(DbType,Dsn,,Username,thePassword)
>     --get revdb_connect("ODBC","ibXTGLocal",,"aUser","aPassword")
>
> If I perform the connection with the commented code it works.
>
> The answer command shows "ODBC","ibXTGLocal",,"aUser","aPassword".
>
> BUT... the connection fails if the connect string consists of the variables
> rather than the literal strings.  This is the case even if I remove the '&
> quote' constants from the values inserted into the variables.
>
> Any suggestions why my code does not work?

I tripped over this one myself a while back.  Check the Transcript dictionary and
you'll see that revdb_connect() requires variable *names*, not variables.  Pretty
subtle.

RR





More information about the use-livecode mailing list