none
oracle client connect error 'Field' but used like a 'Type' RRS feed

  • Question

  • hi masters I faced an error as below,

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Data.OracleClient; using System.Globalization; public partial class VW_debug : System.Web.UI.Page { OracleConnection conn = new OracleConnection(ConfigurationManager.AppSettings["ConnectionString"].ToString()); conn.Open(); ... Conn.Close();

    }


    Am I missing something? very grateful.
    Friday, July 5, 2019 1:51 AM

All replies

  • Hi arlsen,

    Thank you for posting here.

    For your question, you want to solve the error you mentioned. As usual, we could not use method under a class directly(such as conn.open()). Therefore, I suggest that you could try the following code.

    public partial class WebForm1 : System.Web.UI.Page
        {
            OracleConnection conn = new OracleConnection(ConfigurationManager.AppSettings["ConnectionString"].ToString());
            public void connectionstring(OracleConnection oracle)
            {
                oracle.Open();
                oracle.Close();
            }
        }

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, July 5, 2019 2:59 AM
    Moderator
  • thanks jack, it seems doesn't work and I try to insert the sub class ,it works.
    Friday, July 5, 2019 6:32 AM
  • Hi arlsen,

    Thanks for the feedback.

    I want to confirm if your question has been solved. If not, you could refer to the following modified code.

    public partial class WebForm1 : System.Web.UI.Page
        {
         
            protected void Page_Load(object sender, EventArgs e)
            {
                connectionstring(conn);
            }
    
            OracleConnection conn = new OracleConnection(ConfigurationManager.AppSettings["ConnectionString"].ToString());
            public void connectionstring(OracleConnection oracle)
            {
                oracle.Open();
                oracle.Close();
            }
        }

    I forget it that tell you how to use the method, I am sorry for that.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Friday, July 5, 2019 7:35 AM
    Moderator