簡體   English   中英

OLEDB Oracle未指定錯誤(E_FAIL(0x80004005))查詢

[英]OLEDB Oracle Unspecified Error(E_FAIL(0x80004005)) on query

我正在嘗試運行查詢,連接發生,但是當命令執行運行時,我得到上述錯誤。

這是我想要運行的查詢:

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

我的連接字符串:

Provider = OraOLEDB.Oracle; User Id = HR; 密碼= hr;

產品規格:

  • C#WinForms
  • Oracle 11
  • 使用Oracle XE

我試過的步驟:

  • 腳本在實時服務器上的sqldeveloper中運行
  • 連接打開
  • 監聽器已啟動並正在運行
  • 參數'name'和'pwd'通過並被發送

堆棧跟蹤:

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)

我收到錯誤的地方:

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(*)FROMFelhasználókWHEResnév=:névANDjelszó=:jelszó;”

強調的字母是否可能導致編碼錯誤?

嘗試

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

OleDbCommand方法AddWithValue接受Object,這就是為什么你可以將TextBox作為參數傳遞而沒有任何編譯錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM