5 Replies Latest reply on Feb 21, 2013 4:47 PM by Mark Williams-Oracle

    .Net/C# NLog database connection is not working

    979840
      here is my .config file

      <target name="NLOGDatabase" xsi:type="Database" keepConnection="false" useTransactions="true"
      dbProvider="Oracle.DataAccess"
      connectionString="Data Source=devl;User Id=net_app;Password=net_app"
      commandText="insert into net_app.Web_Application_Logging( LOG_LEVEL ,MESSAGE) values( '2','2')">
      <parameter name="LOGLEVEL" layout="${level:uppercase=true}"/>
      <parameter name="MESSAGE" layout="${message}"/>
      </target>

      in my project i have a reference to:

      Oracle.DataAccess version 4.112.3.0

      What am i doing wrong?

      Is there better way to do it?

      Edited by: 976837 on Feb 21, 2013 8:06 AM
        • 1. Re: .Net/C# NLog database connection is not working
          Alex Keh - Product Manager-Oracle
          What error are you receiving?

          I have no knowledge of how to use NLog, but I notice that your user id and password are blank.
          • 2. Re: .Net/C# NLog database connection is not working
            Mark Williams-Oracle
            976837 wrote:
            here is my .config file

            <target name="NLOGDatabase" xsi:type="Database" keepConnection="false"
            useTransactions="true"
            dbProvider="Oracle.DataAccess"
            connectionString="Data Source=devl;User Id=;Password=;Integrated Security=no;"
            commandText="insert into net_app.NLOGTest2( LOG_LEVEL ,MESSAGE) values( :LOGLEVEL,:MESSAGE)">
            <parameter name="LOGLEVEL" layout="${level:uppercase=true}"/>
            <parameter name="MESSAGE" layout="$null"/>
            </target>

            in my project i have a reference to:

            Oracle.DataAccess version 4.112.3.0

            What am i doing wrong?

            Is there better way to do it?
            Hi,

            To add to Alex's comments, "Integrated Security" is not a valid connection string attribute for ODP.NET (I think it is for the MS provider).

            You should receive an exception similar to the following when using that item in an ODP.NET connection string:
            Message='integrated security' is an invalid connection string attribute
            Regards,
            Mark
            • 3. Re: .Net/C# NLog database connection is not working
              979840
              Yes, I removed the login and password when i posted it.

              NLog doesn't throw errors it just doesn't write to the DB.....
              • 4. Re: .Net/C# NLog database connection is not working
                979840
                I removed the integrated security ans it still did not work
                • 5. Re: .Net/C# NLog database connection is not working
                  Mark Williams-Oracle
                  I, like Alex, am not familiar with NLog; howerver, I did an internet search and it seems like this is not an ODP.NET issue, rather, it is an NLog configuration issue.

                  Ref this NLog forum post.

                  From what I gather in that posting you have not correctly specified the value for the dbProvider property.

                  You have:

                  dbProvider="Oracle.DataAccess"

                  Whereas it seems it could be:

                  dbProvider="Oracle.DataAccess.Client"

                  - or -

                  dbProvider="Oracle.DataAccess.Client.OracleConnection, Oracle.DataAccess, Version=<your version here>, Culture=neutral, PublicKeyToken=89b483f429c47342"

                  As a sample, on my machine this would look like:

                  dbProvider="Oracle.DataAccess.Client.OracleConnection, Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342"

                  The documentation of the dbProvider property states:

                  "The parameter name should be a provider invariant name as registered in machine.config or app.config. Common values are:"

                  <snip>
                  Oracle.DataAccess.Client
                  <snip>

                  Alternatively the parameter value can be be a fully qualified name of the provider...

                  Edited by: Mark Williams on Feb 21, 2013 11:43 AM
                  Clarified documentation comment.