Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM SQL » View Thread |
Messages 1 to 10 of 11 total |
ParamByName |
Wed, Jan 11 2017 4:29 PM | Permanent Link |
Ronald | Hi,
I have this sql code: update lists set name=:name, No=:no, WordListmapNo=:wordlistmapno, lines=:lines, tag=:tag where no=:no This works fine for all fields if I use: SQLQuery.ParamByName(FieldName).AsString:=FieldValue But not for the field "Tag" which is an integer, I then MUST use SQLQuery.ParamByName(FieldName).AsIntege:=StrToInt(FieldValue) or else I get Error # 11949 SQL Parsing error... Is this AsString not allowed for integers? Thanks, Ronald |
Wed, Jan 11 2017 4:35 PM | Permanent Link |
Huseyin Aliz myBiss ApS | Ronald,
It's not that easy as changing: SQLQuery.ParamByName(FieldName).AsIntege:=StrToInt(FieldValue) to SQLQuery.ParamByName(FieldName).AsInteger:=StrToInt(FieldValue) Regards, Hüseyin Den 11-01-2017 kl. 22:29 skrev Ronald: > Hi, > > I have this sql code: > > update lists set > name=:name, > No=:no, > WordListmapNo=:wordlistmapno, > lines=:lines, > tag=:tag > where no=:no > > This works fine for all fields if I use: SQLQuery.ParamByName(FieldName).AsString:=FieldValue > But not for the field "Tag" which is an integer, I then MUST use SQLQuery.ParamByName(FieldName).AsIntege:=StrToInt(FieldValue) > or else I get Error # 11949 SQL Parsing error... > > Is this AsString not allowed for integers? > > Thanks, > Ronald > |
Wed, Jan 11 2017 5:12 PM | Permanent Link |
Fernando Dias Team Elevate | Ronald,
The type of the fields must match the parameter types, that's the only rule. -- Fernando Dias [Team Elevate] |
Thu, Jan 12 2017 5:09 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Fernando
>The type of the fields must match the parameter types, that's the only rule. I think what you're saying is the type of the data supplied must match the parameter type eg .AsInteger := 123;. .AsString := '123';. because otherwise I'm baffled. Roy |
Thu, Jan 12 2017 5:09 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Ronald
My guess (which is what I think Fernando is saying) is that it will depend on what the type of FieldValue is. If you're trying to assign an integer to a string it won't work. Roy Lambert |
Thu, Jan 12 2017 5:27 AM | Permanent Link |
Ronald | Roy Lambert wrote:
>My guess (which is what I think Fernando is saying) is that it will depend on what the type of FieldValue is. If >you're trying to assign an integer to a string it won't work. OK, but it is strange because with a TDataSet you can assign an integer with the .AsString:= property. |
Thu, Jan 12 2017 6:10 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Ronald
>>My guess (which is what I think Fernando is saying) is that it will depend on what the type of FieldValue is. If >you're trying to assign an integer to a string it won't work. > >OK, but it is strange because with a TDataSet you can assign an integer with the .AsString:= property. No you can't. If you try the compiler objects. [Pascal Error] Main.pas(1081): E2010 Incompatible types: 'string' and 'Integer' You can apply an integer STRING using .AsString as you can with ParamByName. The other factor is that the parameters inherit from TCollection and the .AsString applies to a TCollectionItem. With a dataset the .AsString applies to a TIntegerField. Roy Lambert |
Thu, Jan 12 2017 6:13 AM | Permanent Link |
Walter Matte Tactical Business Corporation | I'm guessing, did not test - but I would think you need to tell the data type of the parameter if you want to use AsString - other wise it assumes that you need to pass the datatype of the field (tag I assume is an integer in your table).
MyQuery.Params.ParamByName('tag').DataType := ftInteger; MyQuery.Params.ParamByName('tag').AsString := '123'; Walter |
Thu, Jan 12 2017 6:19 AM | Permanent Link |
Ronald | Ronald wrote:
>OK, but it is strange because with a TDataSet you can assign an integer with the .AsString:= property. I mean you can assign an integer fieldtype with the .AsString property. I have tested it further now and it seems that you must explicitly tell what type the field in the table is. So ParamByName('integerfieldintable').AsString:='25' gives you an error. To workaround this I have now added a character to all the fields in the table. The fieldname No is now iNo. My generic post routine (I handle the EWB posts in a databasemodule) then understands what the actual fieldtype is and use .AsInteger in stead of .AsString. That is handy for me, because now I only use 1 TDBISamQuery in my databasemodule to do all the posts for all tables. |
Thu, Jan 12 2017 6:21 AM | Permanent Link |
Walter Matte Tactical Business Corporation | I was wrong - test - Forget that idea... if only worked with AsInteger ...
Walter |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Friday, March 29, 2024 at 03:30 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |