DataGrid Form and mySQL
Posted: Fri May 10, 2013 2:57 am
Hi everyone once again....I need some advice/help here when it comes to importing my "mySQL" database into my dataGrid form. To make it simple on myself (or so I thought), I am only passing a total of 3 fields from my database called "Orders" into my form. Right now, I am only using 2 records from the DB just to see if it works and again to make it simple to debug. Obviously I am doing this all wrong and need to see if anyone can help me with the code on importing individual records into the form. I have been doing some reading over the past two days and finally broke down and am asking for help. I have checked out the lessons section article --> http://lessons.runrev.com/s/lessons/m/d ... ts-of-data but am confused. I have also attempted to deconstruct the crudeDatabase zip but with no avail. My code is below and all I simply want to do is import my records from my database into my DB form. Any help is greatly appreciated.... Kenny
*Edit--I have no problem importing data from the mySQL database when I use the "Table" version of the DG. Since the data being queried from the server comes back in tab delimited form, it imports nicely in each column. Normally I would be okay with this, but I like the fact that you can customize the DG form with your own buttons and such. I wish it was as easy to import data into the form as it is for the table.
on mouseUp
--Connect to the DB
connectMe
-- check the global connection ID to make sure we have a database connection
global gConnectionID
if gConnectionID is not a number then
answer error "Please connect to the database first."
exit to top
end if
-- construct the SQL (this selects all the data from the specified table)
put "SELECT Distinct Name,OrderInfo,Time FROM Orders" into tSQL
-- query the database
put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData
-- check the result and display the data or an error message
if item 1 of tData = "revdberr" then
answer error "There was a problem querying the database:" & cr & tData
else
--This is where I am confused--
//put ?? into theDataA["Name"]
//put ?? into theDataA["OrderInfo"]
//put ?? into theDataA["Time"]
put img id 3510 card "images" into theDataA["image URL"]
put 1 into theLineNo
set the dgData of group "DataGrid" to empty
dispatch "AddData" to group "DataGrid" with theDataA, theLineNo
put the result into theNewIndex -- integer if successful, error string otherwise
end if
end mouseUp
*Edit--I have no problem importing data from the mySQL database when I use the "Table" version of the DG. Since the data being queried from the server comes back in tab delimited form, it imports nicely in each column. Normally I would be okay with this, but I like the fact that you can customize the DG form with your own buttons and such. I wish it was as easy to import data into the form as it is for the table.
on mouseUp
--Connect to the DB
connectMe
-- check the global connection ID to make sure we have a database connection
global gConnectionID
if gConnectionID is not a number then
answer error "Please connect to the database first."
exit to top
end if
-- construct the SQL (this selects all the data from the specified table)
put "SELECT Distinct Name,OrderInfo,Time FROM Orders" into tSQL
-- query the database
put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData
-- check the result and display the data or an error message
if item 1 of tData = "revdberr" then
answer error "There was a problem querying the database:" & cr & tData
else
--This is where I am confused--
//put ?? into theDataA["Name"]
//put ?? into theDataA["OrderInfo"]
//put ?? into theDataA["Time"]
put img id 3510 card "images" into theDataA["image URL"]
put 1 into theLineNo
set the dgData of group "DataGrid" to empty
dispatch "AddData" to group "DataGrid" with theDataA, theLineNo
put the result into theNewIndex -- integer if successful, error string otherwise
end if
end mouseUp