Is there a way to change the field type of a query in delphi without having to delete and include it?

1

I have the following situation, I use PostgreSQL and Zeos in DelphiXE, I needed to update the component to better support LATIN1 x UTF-8, now I can work with all kinds of characters, blz.

But another problem came up, some fields that were Memo type the new version of the component treats as String so the delphi "screams" in the conversion.

The solution is simple, just delete the DataSet field and include it again and it picks up the new type, but my application has almost 400 forms, imagine opening it one by one and checking the components.

I have GExperts installed which gives many treatment options in the project, but I have not found if it does this type change in Fields.

Looking at the fields that delphi complains about, they are like TStringField, but when I try to open the query it gives the message:

---------------------------
Error
---------------------------
zqrClientes: Type mismatch for field 'end_cid', expecting: String actual: Memo.
---------------------------
OK   
---------------------------

If it's already TStringField, then it should not scream, but you know what it's like ... things just happen, so I went there in the Form code to see how it is, it looks like this:

object zqrClientesend_cid: TStringField
      DisplayWidth = 255
      FieldName = 'end_cid'
      ReadOnly = True
      Size = 255
    end

The problem seems to be the size of the field, which at the base is 40 and the component is 255, but changing only the field size does not help.

This field was a varchar without specifying size in Postgres (error in creating the field), in the old component it worked normal even after changing the size to 40 character, but now changing the version of the Zeos component, it shouts. / p>

Where does the delphi store the information that the component is Memo and not String?

I already exclude the DUCs and recompile and nothing.

In summary the question is:

How to change the types of Querys Fields in Delphi without having to delete and re-include, since this action also breaks many links of the components related to the Fields that will be deleted.

    
asked by anonymous 26.04.2018 / 17:24

1 answer

2

I needed to do this shortly, remember, there is .pas and .dfm one of them is not as it should.

Here I have developed a similar solution with another SoPt user.

"The idea is simple", look for an occurrence and replace. One detail is that there was a pattern.

object zqrClientesend_cid: TStringField
      DisplayWidth = 255
      FieldName = 'end_cid'
      ReadOnly = True
      Size = 255
    end

Just use the example of the answer I made and search for it and exchange for what you want!

A detail in your question is that it says to be simple, simply delete the fields and add them again, but beware of the events link ...

    
26.04.2018 / 21:47