Creating Table in SQL database
Posted: Sat Mar 30, 2013 7:16 pm
So I have connected to my SQL database and the connection is confirmed by the answer script displaying: Connection ID = 6
Then I have a separate button to create the table (just for examination purposes) and this is the script I have
on mouseUp
global gConnectionID
if gConnectionID is not a number then
answer error "Please connect to the database first."
exit to top
end if
--the databaseCreateTable handler is on the card script
databaseCreateTable
end mouseUp
On the card:
on databaseCreateTable
## Add a contact_details table to the database
global gConnectionID
put gConnectionID into tDatabaseID
put "CREATE TABLE Table1 (firstName char(30), lastName char(30), birthDate INTEGER" into tSQL
revExecuteSQL tDatabaseID, tSQL
end databaseCreateTable
When I try to enter data into the table, it always replies an error with the reason being: Table alpha2.Table1 does not exist
I have already looked through the tutorials but there is nothing specific about adding a table to an SQL database. Just a general code of which I already followed and tweaked in many ways.
Is there a way that I can confirm that the table is created? Also, because it seems as though I have not done so already, how do I actually create the SQL table with Livecode?
Then I have a separate button to create the table (just for examination purposes) and this is the script I have
on mouseUp
global gConnectionID
if gConnectionID is not a number then
answer error "Please connect to the database first."
exit to top
end if
--the databaseCreateTable handler is on the card script
databaseCreateTable
end mouseUp
On the card:
on databaseCreateTable
## Add a contact_details table to the database
global gConnectionID
put gConnectionID into tDatabaseID
put "CREATE TABLE Table1 (firstName char(30), lastName char(30), birthDate INTEGER" into tSQL
revExecuteSQL tDatabaseID, tSQL
end databaseCreateTable
When I try to enter data into the table, it always replies an error with the reason being: Table alpha2.Table1 does not exist
I have already looked through the tutorials but there is nothing specific about adding a table to an SQL database. Just a general code of which I already followed and tweaked in many ways.
Is there a way that I can confirm that the table is created? Also, because it seems as though I have not done so already, how do I actually create the SQL table with Livecode?