Working on my first sqlite database and need a little help (Thanks for the video Tigg)…
On Page preload I have:
db = SQLite.Open("AutoPlay\\Docs\\accounts.db");
SQLite.Query(db, "CREATE TABLE accounts(ID integer primary key, who text, login text, pass text, notes text)", nil);
function PopLBFromDB()
--select all entries found in the accounts table
tbReturn = SQLite.QueryToTable(db, "SELECT * FROM accounts");
--Clear all items from listbox
ListBox.DeleteItem("who_what_List", LB_ALLITEMS);
--Do the following if there are entries returned
if tbReturn and tbReturn.Rows > 0 then
for i,v in tbReturn.Data do
--Add each item returned from the above query to the listbox
ListBox.AddItem("ListBox1", tbReturn.Data[i]["name"], tbReturn.Data[i]["ID"]);
end
end
end
function Enclose (strText)
--returns the suppied string as a quoted string
return string.format("%q", strTest);
end
function AddtoDB()
local strWho = input.GetText("who_what_Input")
local strLog = input.GetText("login_Input")
local strPass = input.GetText("passsword_Input")
local strNote = input.GetText("notes_Input")
--Check to see if the above entries are valid
if strWho ~= "" and strLog ~= "" and strPass ~= "" and strNote ~= "" then
SQLite.Query(db, "Insert into accounts(name, login, password) values9".. Enclose(strWho)..","..Enclose(strLog)..","..Enclos e(strPass)..","..Enclose(strNotes)..")",nil);
--Clear the inputs
function ClearInputs()
input.SetText("who_what_Input","");
input.SetText("login_Input","");
input.SetText("passsword_Input","");
input.SetText("notes_Inpu","");
end
else
Dialog.Message("Error", "Please provide an Account name, Login and password before trying to add an entry");
end
end
On Page show I have:
PopLBFromDB();
On my “Add” Button on click…
AddtoDB();
PopLBFromDB();
I keep getting an error message when clicking the Add button:
On Click, Line 27: attempt to index global ‘input’ (a nil value)
On Page preload I have:
db = SQLite.Open("AutoPlay\\Docs\\accounts.db");
SQLite.Query(db, "CREATE TABLE accounts(ID integer primary key, who text, login text, pass text, notes text)", nil);
function PopLBFromDB()
--select all entries found in the accounts table
tbReturn = SQLite.QueryToTable(db, "SELECT * FROM accounts");
--Clear all items from listbox
ListBox.DeleteItem("who_what_List", LB_ALLITEMS);
--Do the following if there are entries returned
if tbReturn and tbReturn.Rows > 0 then
for i,v in tbReturn.Data do
--Add each item returned from the above query to the listbox
ListBox.AddItem("ListBox1", tbReturn.Data[i]["name"], tbReturn.Data[i]["ID"]);
end
end
end
function Enclose (strText)
--returns the suppied string as a quoted string
return string.format("%q", strTest);
end
function AddtoDB()
local strWho = input.GetText("who_what_Input")
local strLog = input.GetText("login_Input")
local strPass = input.GetText("passsword_Input")
local strNote = input.GetText("notes_Input")
--Check to see if the above entries are valid
if strWho ~= "" and strLog ~= "" and strPass ~= "" and strNote ~= "" then
SQLite.Query(db, "Insert into accounts(name, login, password) values9".. Enclose(strWho)..","..Enclose(strLog)..","..Enclos e(strPass)..","..Enclose(strNotes)..")",nil);
--Clear the inputs
function ClearInputs()
input.SetText("who_what_Input","");
input.SetText("login_Input","");
input.SetText("passsword_Input","");
input.SetText("notes_Inpu","");
end
else
Dialog.Message("Error", "Please provide an Account name, Login and password before trying to add an entry");
end
end
On Page show I have:
PopLBFromDB();
On my “Add” Button on click…
AddtoDB();
PopLBFromDB();
I keep getting an error message when clicking the Add button:
On Click, Line 27: attempt to index global ‘input’ (a nil value)
Comment