by using
ReadMessage = Input.GetText("WriteInput");
WriteInput = I'm here
it will not write to the db.
It will write everthing else even ? " [ = + @ and so on but will not write a apstrophy.
Please help
Professional Software Development Tools
by using
ReadMessage = Input.GetText("WriteInput");
WriteInput = I'm here
it will not write to the db.
It will write everthing else even ? " [ = + @ and so on but will not write a apstrophy.
Please help
Are you trying to write the input from and input object to a db file?
If i understand you correct then yes.
I type in a Input box and submit it
and it tries to write what i typed to the db but if i type in a apstrophy it will error.
I can type anything else and it works fine.
![]()
I thouth you were writing it to a DatabaseFile with strings,
like this example
cause that option works with apostrophe,Code:ReadMessage = Input.GetText("WriteInput"); TextFile.WriteFromString("Autoplay\\Docs\\MyDatabase.db", ""..ReadMessage, false);
i havent used experimented with sqlite very much and so in that way i dont know if it works or not, hoppefully someone more knowlegable in this area will help you out,
To quote the all-knowing Worm:
"You need to enclose the string that contains the ' in quotes (")
I like to use a function to do it to keep it a little cleaner"
function Enclose(sIn)
return "\""..sIn.."\"";
end
Enclose("You're string here...")
You need to use StringReplace() to replace all instances of the ' with two ' of a same kind:
I'm happy. -----> I''m happy.
This is because of the SQL syntax.
You see, if you don't replace ' with two 's, your query would end up like this, for example:
...which is not good. This is the correct syntax:Code:UPDATE table SET myvalue='I'm happy';
...which will save I'm happy. string into your SQLite database.Code:UPDATE table SET myvalue='I''m happy.';
Last edited by bule; 06-01-2006 at 10:50 AM.
Never know what life is gonna throw at you.
(Based on a true story.)
I don't understand![]()
Name = Label.GetText("Login");
Date = Label.GetText("Date");
Time = Label.GetText("Time");
ReadMessage = Input.GetText("WriteInput");
ToUser = ComboBox.GetText("ComboBox");OpenMessageDatabase();
Light = 0;
sQuery = "INSERT into Message values(NULL, '" .. Name .. "', '" .. Date .. "', '" .. Time .. "', '" .. ToUser .. "', '" .. ReadMessage .. "', '" .. Light .. "')";
AddRow = WriteToDB(db, sQuery);
if AddRow == "OK" then
end
CloseMessageDatabase();
How would i write that?
ok
so i just
Replace
forReadMessage = Input.GetText("WriteInput");
And add thisReadFirst = Input.GetText("WriteInput");
ReadMessage = String.Replace(ReadFirst, "'", "''", false);
Works Nice, thanks
Is there any others i should know about?
Last edited by jfxwave; 06-01-2006 at 05:01 PM.
I myself use this function to overcome this:
I use it like this in the SQL queries:Code:function Q(s) return String.Replace(s.."", "'", "''", false); end
Code:sQuery = "INSERT into Message values(NULL, '" .. Q(Name) .. "', '" .. Q(Date) .. "', '" .. Q(Time) .. "', '" .. Q(ToUser) .. "', '" .. Q(ReadMessage) .. "', '" .. Q(Light) .. "')";
Never know what life is gonna throw at you.
(Based on a true story.)
Hi,
function Enclose(sValue)
return String.Replace(s.."", "'", "''", false);
end
I find it is easy to Enclose the data that has Single Quotes when INSERTing into the SQLite DB. It is also easy to SELECT......and dump it on the screen.
BUT when making that data as the primary SELECT variable, it will not work.
For example:
SELECT Hobby WHERE Name=sName
If variable sName has been Enclose() earlier , there will be SQL error when making it as the primary SELECT variable.
Any thoughts?
Newbie Examples
------> AMS 7.5 : amstudio.azman.info
----> AMS 6 & 5: www.azman.info/ams/
----> FB: facebook.com/GuideToWealth
----> Content Development Blog: www.AZMAN.asia