locked
ODP.Net and Designer-generated code RRS feed

  • Question

  • User85981548 posted

    Hello,

    I'm migrating a legacy ASP.Net 1.1/2.0 application from Microsoft Data Provider for Oracle to ODP.NET and have already encountered SQL statements that stopped working because of incorrect parameter binding. While I understand what I need to do about manually written code, I'm completely lost when it comes to code generated by Visual Studio. There is a lot of declarations in *.ascx.cs files like:

    protected OracleCommandoracleSelectCommand1;
    protected OracleCommandoracleInsertCommand1;
    protected OracleCommandoracleUpdateCommand1;
    protected OracleCommandoracleDeleteCommand1;

    etc.  that are later used in InitializeComponent() methods in these files, which are commented as "Required method for Designer support - do not modify the contents of this method with the code editor."

    When I open the corresponding *.ascx files, I see no mentioning of those OracleCommand objects, so I have no clue based on what this code was generated, where the SQL statements used by those OracleCommand objects come from, and how their arguments are defined. So, could someone please give me some pointers as to how this code is generated and, most importantly, how I can change the BindByName property of all those auto-generated OracleCommand objects so that if the code gets regenerated the change will remain or ensure that Parameters are added in the same order as they appear in the SQL statements?

    BTW, such declarations and InitializeComponent() methods can be found in a couple of pure *.cs files that do not have any associated *.ascx or *.aspx files, which makes them even more puzzling...

    Best regards,
    Konstantin

    Monday, October 29, 2018 9:28 AM

All replies

  • User-893317190 posted

    Hi Konstantin Goldobin,

    Here is  a link about auto-generated code in visual studio, maybe you could consider Resharper.

    https://stackoverflow.com/questions/2600025/can-you-change-vs-win-forms-designer-code-generation

    In addition,this is a forum about asp.net(only have webform instead of winform.).

    If it is not your case ,you could refer to winform's forum for help.

    https://social.msdn.microsoft.com/Forums/windows/en-US/home?forum=winforms

    Best regards,

    Ackerly Xu

    Tuesday, October 30, 2018 5:19 AM
  • User85981548 posted

    Hi,

    Thanks for your answer! I'm dealing with a web ASP.NET application, so I guess it means I'm dealing with webforms and this is a correct forum. This link you provided is about server-side controls that are placed on a page and the code generated for them in code-behind files. My question is about code generation for things that I can't find any reference to in aspx/ascx files, like a bunch of OracleCommand objects. I also noticed that there are fields generated for other things that are not present on the webforms, like OracleDataAdapter and DataSet objects and I guess it is all related, but what I cannot figure out is how these things were added to aspx/ascx pages, where I can find them when I open the aspx/ascx pages in Designer, and how I can customise them for use with ODP.NET.

    Best regards,
    Konstantin

    PS I've just noticed that my post was moved to this section by someone. I initially created it in the Getting Started section.

    Tuesday, October 30, 2018 9:53 AM
  • User1120430333 posted

    I'm migrating a legacy ASP.Net 1.1/2.0 application from Microsoft Data Provider for Oracle to ODP.NET and have already encountered SQL statements that stopped working because of incorrect parameter binding. While I understand what I need to do about manually written code, I'm completely lost when it comes to code generated by Visual Studio. There is a lot of declarations in *.ascx.cs files like

    You are trying to come from .NET Framework 1.1 and 2.0 to a current .NET Framework technology doing some kind of migration? No, you should be doing a conversion,  re-write of the entire solution, becuase you'll be facing a whole lot of problems IMO. 

    Tuesday, October 30, 2018 11:05 AM
  • User85981548 posted

    Hi,

    Thanks! For now I'm only moving it from MS data provider for Oracle to ODP.Net.

    Best regards,
    Konstantin

    Tuesday, October 30, 2018 11:59 AM