PDA

View Full Version : Help to get error in SQLite searching


dmla
04-07-2005, 06:21 AM
This function is for word searching in SQLite database. I cannot get error message. I need to write "Word was not find" when it will be an error during sqlite searching. HELP ME PLEASE.



tWords_Selected = SQLite.QueryToTable (db, "Select * from Words Where Label='"..input_result.."'");
if tWords_Selected.Data[1]["Label"] ~= nil then
word_id = tWords_Selected.Data[1]["RecordID"];
word_label = tWords_Selected.Data[1]["Label"];
word_text = tWords_Selected.Data[1]["Text"];
word_sound = tWords_Selected.Data[1]["Sound"];
speak_word();
Paragraph.SetText("label", word_label);
Paragraph.SetText("text", word_text);

if word_id == 1 then
Button.SetVisible("ButtonLeft", false);
Button.SetVisible("ButtonRight", true);
end
if word_id == word_id_max then
Button.SetVisible("ButtonLeft", true);
Button.SetVisible("ButtonRight", false);
end
end

Worm
04-07-2005, 07:12 AM
tWords_Selected = SQLite.QueryToTable (db, "Select * from Words Where Label='"..input_result.."'");
if tWords_Selected.Data[1]["Label"] ~= nil then
word_id = tWords_Selected.Data[1]["RecordID"];
word_label = tWords_Selected.Data[1]["Label"];
word_text = tWords_Selected.Data[1]["Text"];
word_sound = tWords_Selected.Data[1]["Sound"];
speak_word();
Paragraph.SetText("label", word_label);
Paragraph.SetText("text", word_text);

if word_id == 1 then
Button.SetVisible("ButtonLeft", false);
Button.SetVisible("ButtonRight", true);
end
if word_id == word_id_max then
Button.SetVisible("ButtonLeft", true);
Button.SetVisible("ButtonRight", false);
end
else
--display your message here
end

dmla
04-07-2005, 08:53 AM
I did it, but it writes next message:


Error
On Key, Line 47: attempt to index field '?' (a nil value)

Need some more help :(:(:(

Worm
04-07-2005, 09:11 AM
tWords_Selected = SQLite.QueryToTable (db, "Select * from Words Where Label='"..input_result.."'");
if tWords_Selected.Rows > 0 then
word_id = tWords_Selected.Data[1]["RecordID"];
word_label = tWords_Selected.Data[1]["Label"];
word_text = tWords_Selected.Data[1]["Text"];
word_sound = tWords_Selected.Data[1]["Sound"];
speak_word();
Paragraph.SetText("label", word_label);
Paragraph.SetText("text", word_text);

if word_id == 1 then
Button.SetVisible("ButtonLeft", false);
Button.SetVisible("ButtonRight", true);
end
if word_id == word_id_max then
Button.SetVisible("ButtonLeft", true);
Button.SetVisible("ButtonRight", false);
end
else
--display your message here
end

dmla
04-07-2005, 09:20 AM
BIGBIGBIG THNX - topic is closed
BIG THANX. Everything is working. Topic can be closed.