Thank you Bisonte, Your code example seems to work although I am not clear as to what the "VALUES(?, ?)" is doing?
The database has 23 tables and the variable 'tablename' holds the value of the table that was selected from the ListView. It works fine.
Thanks again for the help and the code example.
Problem writing to database
Re: Problem writing to database
http://www.oldtimeradiotoday.com - Listen to or download classic old time radio broadcasts.
Re: Problem writing to database
basically, what Bisonte's code is doing is with these lines,
is assigning the strings "name" and "code" to the question marks in the query, without you having to alter the strings beforehand
nice fix btw, Bisonte, I never really got around to learning SetDatabaseString
Code: Select all
SetDatabaseString(#dbaseID, 0, name)
SetDatabaseString(#dbaseID, 1, code)
nice fix btw, Bisonte, I never really got around to learning SetDatabaseString
there is no sig, only zuul (and the following disclaimer)
WARNING: may be talking out of his hat
WARNING: may be talking out of his hat
- Fangbeast
- PureBasic Protozoa
- Posts: 4747
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Re: Problem writing to database
And I forgot these were there or I would have done all my code that way instead of the huge concatenated string mess that I keep using.
Doesn't "SetDatabaseString" eliminate the need for escaping strings as it's a paramaterised insert etc?
Doesn't "SetDatabaseString" eliminate the need for escaping strings as it's a paramaterised insert etc?
Amateur Radio, D-STAR/VK3HAF
Re: Problem writing to database
Sorry, I don't know exactly. But : Ever escape your strings if there are special characters in it.Fangbeast wrote:And I forgot these were there or I would have done all my code that way instead of the huge concatenated string mess that I keep using.
Doesn't "SetDatabaseString" eliminate the need for escaping strings as it's a paramaterised insert etc?
I prepare the strings, that I set with SetDataBaseString. And I got no errors
- Fangbeast
- PureBasic Protozoa
- Posts: 4747
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Re: Problem writing to database
Wish I could remember it. Somewhere on the forum last year.Sorry, I don't know exactly.
Amateur Radio, D-STAR/VK3HAF
Re: Problem writing to database
Thanks to all for the help on this one. It had me baffled!
Cheers
Cheers
http://www.oldtimeradiotoday.com - Listen to or download classic old time radio broadcasts.
Re: Problem writing to database
It does eliminate the need to escape a string. The strings aren't interpreted when does this way because they don't become part of the statement string; they are used as is to fill in the blanks, referenced by '?'.Fangbeast wrote:And I forgot these were there or I would have done all my code that way instead of the huge concatenated string mess that I keep using.
Doesn't "SetDatabaseString" eliminate the need for escaping strings as it's a paramaterised insert etc?
This method also prevents clever or maliciously constructed strings from altering what the statement does according to what they contain. This was the unwanted side-effect columbo was having a problem with. It is caused by the total contents of the concatenated string having to be parsed to determine it's effect.