Using a card to make modifications to database
Jim Ault
JimAultWins at yahoo.com
Tue Oct 4 22:31:05 EDT 2005
Quick answer - you are indeed storing the id in a variable, but it is a
local variable (temporary) that disappears as soon as the 'end mouseUp' is
reached. That's why the programmers like to use a 't' in front.. to mean
only for this handler.
There are a few options for storing any value that you need to use the next
time a handler(any handler) is used.
-1- a global variable which is available any where in Revolution, by any
stack or object
-2- a field on a card which is available when on that card
-3- a custom property of any stack which is available when the stack is in
memory (does not have to be open, just in memory)
-4- other options abound, but these should get you started
In the case of only one database being open
Check out Rev help:Topics:Database Operations:
How do I find out which databases are open? -> will get the id for you, even
if you lost the variable somehow, or don't want to store it.
Jim Ault
Las Vegas
On 10/4/05 5:23 PM, "Fred Giannetto" <fgiannet at hotmail.com> wrote:
> Here is a copy of my script. The point is for users to enter data into the
> card and the submit button have the data inserted into the database. The
> sql works when submitted directly into the database.
>
> on mouseUp
> put field "Name" into tName
> put field "Team" into tTeam
> put field "Position" into tPosition
> put field "Rushing" into tRushing
> put field "Receiving" into tReceiving
> get revOpenDatabases("MYSQL", "localhost", "test", root, root1)
> put it into tDatabaseID
> answer tName, tTeam, tPosition, tRushing, tReceiving, tDatabaseID
> revExecuteSQL tDatabaseID,"insert into test.nflstats(Name, Team, Position,
> Rushing, Receiving) values(tName, tTeam, tPosition, tRushing, tReceiving)"
> end mouseUp
>
> I have the tDatabaseID variable to make sure I am recording the Database ID
>
> Thank you for your assistance, There will be a lot of progress once I get
> past these elementary hurdles
> All best Always
> Fred
>
>> From: "Fred Giannetto" <fgiannet at hotmail.com>
>> Reply-To: How to use Revolution <use-revolution at lists.runrev.com>
>> To: use-revolution at lists.runrev.com
>> Subject: Using a card to make modifications to database
>> Date: Tue, 04 Oct 2005 19:00:36 -0400
>>
>> Hello,
>>
>> Trying to have a card submit changes to MySQL database. The syntax for
>> revExecuteSQL requires me to use database ID.
>>
>> How do I do this as the database ID is always changing. I have used the
>> revOpenDatabase function to get it but the ID did not seem to work (I have
>> the right priviledges) and I want the card to be able to apply changes
>> everytime without modifications.
>>
>> All best Always
>> Fred
>>
More information about the use-livecode
mailing list