Inconsistency?
Ivan Smahin
ivan_smahin at paradigmasoft.com
Tue Nov 18 23:13:31 CST 2014
Hi,
On Nov 18, 2014, at 16:48, Karl Grob <kgrob at mus.ch> wrote:
> Hi
>
> I do not understand why the first one works and the second one doesn’t.
> The error resides in p (if I try INSERT only with fldCharPict and p it throws the same error).
>
> Karl
>
> ——————————————————————————
>
>
> tblFonts.setOneRecordClassWay
>
> Private Shared Function setOneRecord(char as string, Fontname as string, Fontsize as double, Fontstyle as cl_S tyle.Styles, charPict as picture, baseline as double, italicWidth as double) As Integer
>
> dim s, p as string
> p = PicturetoBinaryStringMBS(charPict)
>
> myDB.Table(name).SetBlank
> myDB.Table(name).VarBinaryField(fldCharPict).SetString(p)
> Win_Zaehler.res = myDB.Table(name).AddRecord
>
> End Function
>
> This one works
>
> ——————————————————————————
>
> tblFonts.setOneRecord
>
> Private Shared Function setOneRecord(char as string, Fontname as string, Fontsize as double, Fontstyle as cl_Style.Style s, charPict as picture, baseline as double, italicWidth as double) As Integer
>
> dim res as Integer dim s, p as string
>
> p = PicturetoBinaryStringMBS(charPict)
>
> s = "INSERT INTO " + NAME + "(„
> s = s + fldChar + ", "
> s = s + fldCharPict + ", "
> s = s + fldFontName + ", "
> s = s + fldFontSize + ", "
> s = s + fldFontStyle + ", "
> s = s + fldFontBaseline + ", "
> s = s + fldItalicWidth +
> s = s + ") VALUES( "
> s = s + "'" + char + "', "
> s = s + "'" + p + "', „ //error 462848. no string value
> s = s + "'" + Fontname + "', "
> s = s + "" + str(Fontsize) + ", "
> s = s + "" + str(Integer(Fontstyle)) + ", „
> s = s + "" + str(baseline) + ", "
> s = s + "" + str(italicWidth) + ")"
>
> res = myDB.SqlExecute(s)
> myDB.Flush
> return res
> This one does not work, ErrorNumber 462848
Obviously PicturetoBinaryStringMBS produces some "binary string" which is actually not a string but some byte array.
It is ok to use it directly with FBL approach, but SQL parser expects any string literal to be a valid string.
I guess if you try to print out SQL statement above you will see what I mean.
Please, take a look at "binding" SQL approach - see V4RB examples and wiki for details.
--
Best regards,
Ivan Smahin
Senior Software Engineer
Paradigma Software, Inc
Valentina - The Ultra-Fast Database
http://www.valentina-db.com
More information about the Valentina
mailing list