Search code examples
.netvisual-studio-2012resxvisual-studio-designer

Why does visual studio put CommandText in resx resource file vs designer code behind file?


Sometimes my queries that are stored in OdbcCommand.CommandText are saved to the designer.cx code behind, and sometimes in the .resx resource file. What causes it to go to the code behind vs the resource file?

And is there a way to force visual studio to save my queries in the resource file (or vice versa) so I'm not having to look in both places.


Solution

  • Finally, after some googling I found the answer posted here:

    I have examined it a little further. It appears that the commandtext is saved in the resource when it's length is more the 200 characters. This not only applies to the commandtext property, but to all string properties, e.g. the Label.Text. It's saved to the resouce even if the localizable property of the form, usercontrol or component is false. When you decrease the length of the string, the property is removed from the resource file and placed in the Designer.cs file. So it seems you have no control over the fact if a lengthy string is saved in the resource or not. In the case of the commandtext that's very dangerouse, because a translator of the resource could change the commandtext to a wrong statement.

    Apparently there's not way to change this behavior. I did confirm there is a 200 character limit excluding white space.