Search code examples
c#oracleoledb

OLEDB Oracle Unspecified Error(E_FAIL(0x80004005)) on query


I'm trying to run a query, the connection happens, but when the command execution runs, I get the above error.

Here is the query I want to run:

SELECT COUNT(*) FROM Users WHERE name = :name AND pwd = :pwd;

My Connection String:

Provider=OraOLEDB.Oracle;User Id = HR; Password = hr;

Specifications:

  • C# WinForms
  • Oracle 11
  • Using Oracle XE

Steps I've tried:

  • Script runs in sqldeveloper on the live server
  • Connection opens
  • Listener is up and running
  • Parameters 'name' and 'pwd' got through and are sent

StackTrace:


        System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
       a következő helyen: System.Data.OleDb.OleDbCommand.ExecuteCommandTextForMultpleResults(tagDBPARAMS dbParams, Object& executeResult)
       a következő helyen:     System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
       a következő helyen: System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
       a következő helyen: System.Data.OleDb.OleDbCommand.ExecuteScalar()
       a következő helyen: Tudásbázis.Bejelentkezes.BejelentkezésButton_Click(Object sender, EventArgs e) hely: D:\Repos\Tudásbázis\Tudásbázis\Bejelentkezes.cs, sor: 34
       a következő helyen: System.Windows.Forms.Control.OnClick(EventArgs e)
       a következő helyen: System.Windows.Forms.Button.OnClick(EventArgs e)
       a következő helyen: System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       a következő helyen: System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       a következő helyen: System.Windows.Forms.Control.WndProc(Message& m)
       a következő helyen: System.Windows.Forms.ButtonBase.WndProc(Message& m)
       a következő helyen: System.Windows.Forms.Button.WndProc(Message& m)
       a következő helyen: System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       a következő helyen: System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       a következő helyen: System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       a következő helyen: System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       a következő helyen: System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       a következő helyen: Tudásbázis.Program.Main() hely: D:\Repos\Tudásbázis\Tudásbázis\Program.cs, sor: 19
       a következő helyen: System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       a következő helyen: System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       a következő helyen: Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       a következő helyen: System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       a következő helyen: System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       a következő helyen: System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       a következő helyen: System.Threading.ThreadHelper.ThreadStart()System.Data.OleDb.OleDbException (0x80004005): Meghatározatlan hiba: E_FAIL(0x80004005)
       a következő helyen: System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
       a következő helyen: System.Data.OleDb.OleDbCommand.ExecuteCommandTextForMultpleResults(tagDBPARAMS dbParams, Object& executeResult)
       a következő helyen: System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
       a következő helyen: System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
       a következő helyen: System.Data.OleDb.OleDbCommand.ExecuteScalar()
       a következő helyen: Tudásbázis.Bejelentkezes.BejelentkezésButton_Click(Object sender, EventArgs e) hely: D:\Repos\Tudásbázis\Tudásbázis\Bejelentkezes.cs, sor: 34
       a következő helyen: System.Windows.Forms.Control.OnClick(EventArgs e)
       a következő helyen: System.Windows.Forms.Button.OnClick(EventArgs e)
       a következő helyen: System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       a következő helyen: System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       a következő helyen: System.Windows.Forms.Control.WndProc(Message& m)
       a következő helyen: System.Windows.Forms.ButtonBase.WndProc(Message& m)
       a következő helyen: System.Windows.Forms.Button.WndProc(Message& m)
       a következő helyen: System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       a következő helyen: System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       a következő helyen: System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       a következő helyen: System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       a következő helyen: System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       a következő helyen: Tudásbázis.Program.Main() hely: D:\Repos\Tudásbázis\Tudásbázis\Program.cs, sor: 19
       a következő helyen: System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       a következő helyen: System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       a következő helyen: Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       a következő helyen: System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       a következő helyen: System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       a következő helyen: System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       a következő helyen: System.Threading.ThreadHelper.ThreadStart()
    An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
    Additional information: Meghatározatlan hiba: E_FAIL(0x80004005)

Where I get the error:


            using (OleDbConnection connection = new OleDbConnection(ApplicationStrings.ConnectionString))
            {
                using (OleDbCommand command = connection.CreateCommand())
                {
                    connection.Open();

                    command.CommandText = QueryString;

                    command.Parameters.AddWithValue("név",NévTextBox);
                    command.Parameters.AddWithValue("jelszó",_jelszó);

                    int number = (int) command.ExecuteScalar(); //This is the line that throws the error
    }
    }

Where QueryString = "SELECT COUNT(*) FROM Felhasználók WHERE név = :név AND jelszó = :jelszó;"

Is it possible that the accentuated letters are causing a coding error?


Solution

  • Try

     command.Parameters.AddWithValue("név",NévTextBox.Text);
    

    The OleDbCommand method AddWithValue accepts Object and that's why you can pass a TextBox as a parameter without any compile error.