PDA

View Full Version : I am not seeing it but the mistake is there


synistics
03-26-2007, 06:22 AM
First crack at this and followed it through to the end, but it is not putting the data into the DB file. The dummy line I wrote directly in is showing in the list.box, but not the entered data into the form.




function PopLBFromDB()
tbReturn =SQLite.QueryToTable(db, "SELECT * FROM signup");

--clear items from listbox
--ListBox.DeleteItem("LB", LB_ALLITEMS);
--do the following if there are rows
if tbReturn and tbReturn.Rows > 0 then
for i,v in tbReturn.Data do
ListBox.AddItem ("LB", tbReturn.Data [i]["FIRST_NAME"], tbReturn.Data [i]["LAST_NAME"], tbReturn.Data [i]["ADDRESS"], tbReturn.Data [i]["ADDRESS2"], tbReturn.Data [i]["TOWN"], tbReturn.Data [i]["PROV_ST"], tbReturn.Data [i]["COUNTRY"], tbReturn.Data [i]["POSTAL"], tbReturn.Data [i]["DAY"], tbReturn.Data [i]["NIGHT"], tbReturn.Data [i]["EMAIL"], tbReturn.Data [i]["EMAIL2"], tbReturn.Data [i]["PASS"], tbReturn.Data [i]["PASS2"], tbReturn.Data [i]["SUBSCRIPTION"]);
end
end
end

function Enclose(strText)
return string.format("%q",strText);
end

function AddtoDB()
local strFIRST = Input.GetText("FIRST");
local strLAST = Input.GetText("LAST");
local strADDRESS = Input.GetText ("ADDRESS");
local strADDRESS2 = Input.GetText ("ADDRESS2");
local strTOWN = Input.GetText ("TOWN");
local strPROV = Input.GetText ("PROV");
local strCOUNTRY = Input.GetText ("COUNTRY");
local strPOSTAL = Input.GetText ("POSTAL");
local strDAY = Input.GetText ("DAY");
local strNIGHT = Input.GetText ("NIGHT");
local strEMAIL = Input.GetText ("EMAIL");
local strEMAIL2 = Input.GetText ("EMAIL2");
local strPASS = Input.GetText ("PASS");
local strPASS2 = Input.GetText ("PASS2");
local strSUBSCRIPTION = Input.GetText ("SUBSCRIPTION");
--if strFIRST ~= "" and strLAST ~= "" and strADDRESS ~= "" and strADDRESS2 ~= "" and strTOWN ~= "" and strPROV ~= "" and strCOUNTRY ~= "" and strPOSTAL ~= "" and strDAY ~= "" and strNIGHT ~= "" and strEMAIL ~= "" and strEMAIL2 ~= "" and strPASS ~= "" and strPASS2 ~= "" and strSUBSCRIPTION ~= "" then
result = Dialog.Message("Welcome ", Enclose(strFIRST)..Enclose(strLAST)..Enclose(strSU BSCRIPTION));
--insert data into database db
SQLite.Query(db, "Insert into signup(FIRST, LAST, ADDRESS, ADDRESS2, TOWN, PROV, COUNTRY, POSTAL, DAY, NIGHT, EMAIL, EMAIL2, PASS, PASS2, SUBSCRIPTION) values("..Enclose(strFIRST)..", "..Enclose(strLAST)..", "..Enclose(strADDRESS)..", "..Enclose(strADDRESS2)..", "..Enclose(strTOWN)..", "..Enclose(strPROV)..", "..Enclose(strCOUNTRY)..", "..Enclose(strPOSTAL)..", "..Enclose(strDAY)..", "..Enclose(strNIGHT)..", ".. Enclose(strEMAIL)..", "..Enclose(strEMAIL2)..", "..Enclose(strPASS)..", "..Enclose(strPASS2)..", "..Enclose(strSUBSCRIPTION)..")",nil);
--Application.GetLastError ()

--else
--result = Dialog.Message("Notice", "You must enter all of the fields of information before you can continue with the signup process", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);


end


thanks for any help

TJ_Tigger
03-26-2007, 09:03 AM
The ListBox.AddItem only allows three parameters. You are tyring to put everything into the listbox as if it were a grid. What do you actually want to display in the listbox? Do you want to show everything like a spreadsheet, if so then I would look at the Datagrid plugin from IcyNorth. Or if you only want first name and last name then concatenate those items together in the text section and put a unique id into the Data portion like this.

ListBox.AddItem ("LB", tbReturn.Data [i]["FIRST_NAME"] .." ".. tbReturn.Data [i]["LAST_NAME"], tbReturn.Data [i]["UNIQUE_KEY"]);

This of course assumes that you have a unique ID for each row in the database.

Tigg

synistics
03-26-2007, 11:06 AM
I should have explained better but exhaustion was getting me.

The box, which thank you is one thing, the issue is that on hitting the button on the my page, the list box is added another representation of the dummy data I manually inserted through SQLite browser.

When checking the DB with Browser, the new data entered has not been added into the DB. The display in list box is for me right now and yes going forward I want may want to use it for a verification and have the user agree and then submit the information to the server via php or I may just make that function flow straight through and keep a copy local and send up to the server with the same button push.

Right now, there is nothing to send, because it just is not getting added to DB.

Thanks

Synistics

RizlaUK
03-26-2007, 11:26 AM
ok, heres what i would do

finish your error checking ie:

--Application.GetLastError ()-- replace this line of code with the below code


error = Application.GetLastError();
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
end

then try and add the data to the database again


my bet is that you will get "SQL Logic or missing database error"

if so, check the order of your sql query, it must match the order in wich you created the database

synistics
03-26-2007, 11:46 AM
ok, heres what i would do



then try and add the data to the database again


my bet is that you will get "SQL Logic or missing database error"

if so, check the order of your sql query, it must match the order in wich you created the database

off to check will post outcome

thanks

synistics
03-26-2007, 11:56 AM
I had made a change on the action page expanding names from FIRST to FIRST_NAME, followed it through to the list box, but no further. Reverting back to the simple name populates the database and now I am ready for the next mountain to climb

Thanks all for the help