libdatabase : connection problem

Dan Shafer revdan at danshafer.com
Sun Aug 28 21:12:39 EDT 2005


Off-hand I spotted a couple of potential problem spots (haven't spent  
a lot of time analyzing whether these are the only problems):

On Aug 28, 2005, at 2:46 AM, Revolution wrote:

> Sunday, August 28, 2005 12:45:34 PM (GMT +02:00)
>
> event from button :
>
>   local tDbA = ""
>   local i = 0
>   local tDataA = ""
The above lines are doing nothing for you because they are incorrect  
syntax for Revolution. The expression "i = 0" evaluates to either  
true or valse but does nothing with the result. IF what you intend to  
do here is to initialize local variables, then you need the slightly  
more verbose:

local tDbA
put empty into tDbA (or you can use double quotes instead of "empty")
local i
put 0 into i
local tDataA
put empty into tDataA

Having said that, it is strictly optional in Transcript to use the  
word "local" and I'd venture to say that the vast majority of us  
never use it. Variables are local unless they're explicitly defined  
to be global. In that case, you eliminate the three "local" lines in  
the above and just assign the initialization values to the variables  
with the same effect.

>
>         put "mysql" into tDbA["Type"]
>         if dbaddress is empty then put "127.0.0.1" into dbaddress
>         put fld "dbaddress" into tDbA["Host"]

With the above two lines, I *assume* you think you've placed what's  
in the *variable* dbaddress into tDbA["Host"] but you haven't.  
Because you either need to put dbaddress into field "dbaddress" or  
use "put dbaddress into tDbA["Host"] for this to work. Right now,  
there's no connection between the address generated by the second  
line and the array setup on the third line.

Given what I see in the rest of your code, my guess is you want to  
have the second line be:

if fld "dbaddress" is empty then put "127.0.0.1" nto fld "dbaddress"

>         put "bb" into tDbA["Name"]
>         put fld "dbuser" into tDbA["Username"]
>         put fld "dbpassword" into tDbA["Password"]
>
>
>         libDB_RegisterDatabase "BBDataBase", tDbA
>         libDB_Connect "BBDataBase"
>
>      if libDB_GetDBConnectionID("BBDataBase") is an integer then
>       put "status : connected" into fld "statuslabel"
>      else
>       put "status : NOT connected" into fld "statuslabel"
>      end if
>
>
>
> what's wrong ?
>
> it doesn't connect ?
>
> thank you.
>
> regards,
> Adrian C.
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list