我試圖從SQL Server上的存儲過程中提取DateTime
。從存儲過程錯誤中獲取DateTime
存儲過程變量:
@TempDateTime DateTime = '' OUTPUT
SET @TempDateTime = GETDATE()
線的錯誤出在我的C#CF 2.0計劃
DateTime tempDT = Convert.ToDateTime(sqlcmd.Parameters["@TempDateTime"].Value);
我碰到下面的錯誤,我在失去它是什麼。我的存儲過程可以發回一個空嗎?我執行存儲過程,並在另一個代碼上運行正常。獲取DateTime
並將其插入表中,但是當我嘗試檢索DateTime
變種時發生錯誤。
System.IndexOutOfRangeException了未處理
消息= 「一個的{0} {1} '{2}' 不受此包含{3}」。堆棧跟蹤:
在System.Data.SqlClient.SqlParameterCollection.RangeCheck()
在System.Data.SqlClient.SqlParameterCollection.get_Item()
在Missouri_Scanning_Utility.Form1.updateDatabase()
在Missouri_Scanning_Utility.Form1 .tmrUpdateDatabase_Tick()
在System.Windows.Forms.Timer._WnProc()
在System.Windows.Forms.ApplicationThreadContext._InternalContextMessages()
在Microsoft.AGL.Forms.EVL.EnterMainLoop()
在System.Windows.Forms.Application.Run()
在Missouri_Scanning_Utility.Program.Main()
我編輯了自己的冠軍。請參閱:「[應該在其標題中包含」標籤「](http://meta.stackexchange.com/questions/19190/)」,其中的共識是「不,他們不應該」。 –
您是否將C#代碼中的'@ TempDateTime'參數定義爲輸出? 'Direction = ParameterDirection.Output' –
@JasonFaulkner我只是這樣做了,現在該行代碼得到了與上面相同的錯誤。 – Lgwells1