我打算從視圖模型調用存儲過程到ActionResult中。索引超出範圍異常(在位置0處沒有行)
當我試圖運行我的代碼我得到一個錯誤
IndexOutOfRangeException是由用戶代碼來處理 - 在位置0
沒有行這是一個新創建的表是空的但爲什麼存儲過程不會被觸發來插入數據?這是我的代碼。
調用過程CreateSecureRequestOutcome
public static void CreateSecureRequestOutcome(
OracleTransaction trans,
dsAdmin.SECURE_REQUEST_OUTCOMESRow outcomeRow)
{
using (OracleCommand cm = new OracleCommand())
{
cm.Connection = trans.Connection;
cm.Transaction = trans;
cm.CommandText = "TheService.PKG#SECURE_REQUEST.SECURE_REQUEST_OUTCOME";
cm.CommandType = CommandType.StoredProcedure;
cm.AddToStatementCache = true;
OracleParameter param = cm.Paramaters.Add("P_KEEP_PERSON_ID", OracleDBType.Decimal, Paremeter.Direction.Input);
param.Value = keepPersonID;
param = cm.Paramaters.Add("P_SECURE_REQUEST_GUID", OracleDBType.Raw, 16, null, Paremeter.Direction.Input);
param.Value = outcomeRow.SECURE_REQUEST_GUID;
param = cm.Parameters.Add("P_OUTCOME_TIMESTAMP", OracleDBType.Object, Paremeter.Direction.Output);
}
}
cm.ExecuteNonQuery();
IdentityConfirmed視圖模型控制器
[httpPost]
public ActionResult IdentityConfirmed(FormCollection collection)
{
dsAdmin.SECURE_REQUESTS_OUTCOMESRow secReqOutRow;
using (OracleConnection cn = new OracleConnection (OracleConnectionManager.GetProxyServiceConnetionString()))
{
cn.Open();
using (OracleTransaction trans = cn.BeginTransaction())
{
using (Data.dsAdminTableAdapters.SECURE_REQUESTS_OUTCOMESTableAdapter taOut = new Data.dsAdminTableAdapters.SECURE_REQUESTS_OUTCOMESTableAdapter();
{
typedDatasetFiller.ApplyConnection(taOut, cn);
secReqOutRow = taOut.GetDataBySecureGUID(request.ToByteArray())[0];
}
secReqOutRow.OUTCOME_TIMESTAMP = DateTime.Now.AddMonths(1);
Support.CreateSecureRequestOutcome(trans, secReqOutRow);
trans.Commit();
}
cn.Close();
}
retrun View("IdentityConfirmed", vm);
}
你有沒有在Google搜索你的例外訊息?在哪一行你會得到這個錯誤? –
我在這裏得到錯誤secReqOutRow = taOut.GetDataBySecureGUID(request.ToByteArray())[0]; – Gee
在將索引器添加到索引器之前,您應該首先檢查'secReqOutRow'是否包含數據。 – Abbas