Hi,
I have MySQL database, but its only two-column,
Store Sales
Store_a 1.000.000
Store_b 500.000
How to change the sales value-based from store name,
I have done with this code but no luck.
any helps ?
[code] dim aa,bb,cc,dd as string
dim fdz as folderitem
dim tisx as TextInputStream
fdz =GetFolderItem(“store” )
if fdz <> nil and fdz.Exists then
tisx = fdz.OpenAsTextFile
aa=tisx.Readline.Trim
end if
bb=Lowercase(aa)
dim ps as MySQLPreparedStatement
mDB.Prepare(“UPDATE livereport SET sales = ? WHERE shop = ?”)
ps.BindType(0,MySQLPreparedStatement.MYSQL_TYPE_STRING)
ps.BindType(1,MySQLPreparedStatement.MYSQL_TYPE_STRING)
ps.Bind(0,TextField4.text)
ps.Bind(1,bb)
ps.SQLExecute[/code]
thanks
regards,
arief
Is the first column named “Store” or “shop”? Your example list uses “Store” but your prepared statement uses “shop”.
Also, is the sales column a numeric data type? If so, then trying to update it with a string will likely cause problems.
yes sorry I mistyped, The column name is shop
thanks
arief
It looks like you have not assigned your prepared statement to your dimmed ps variable
[quote] dim ps as MySQLPreparedStatement
mDB.Prepare(“UPDATE livereport SET sales = ? WHERE shop = ?”)[/quote]
should be
dim ps as MySQLPreparedStatement = mDB.Prepare("UPDATE livereport SET sales = ? WHERE shop = ?")
or
[code] dim ps as MySQLPreparedStatement
ps = mDB.Prepare(“UPDATE livereport SET sales = ? WHERE shop = ?”)[/code]
My Mistake, defining the wrong variable.
thanks
regards,
arief
Jay_Madren
(Jay Madren)
October 2, 2019, 12:18pm
6
[quote=456169:@Arief Sarjono]My Mistake, defining the wrong variable.
[/quote]
No, the mistake is as Tim stated - you are not assigning the output of the Prepare method to any variable. You should be getting a compile error on the Prepare line as the Prepare method returns a PreparedStatement which you’re not doing anything with.