我想从视图模型中将存储过程调用到ActionResult中。
输入变量nGUID是一个字符串,KeepPersonID和dropPersonID都是十进制类型。当我尝试运行我的代码时出现错误'无法将类型十进制隐式转换为字符串' 这是我的代码。
调用过程MergeAuthIDs
public static void MergeAuthIDs(
OracleTransaction trans, decimal KeepPersonID, decimal dropPersonID)
{
using (OracleCommand cm = new OracleCommand())
{
cm.Connection = trans.Connection;
cm.Transaction = trans;
cm.CommandText = "TheService.PKG#IDENTITIES.Merge_Auth_Ids";
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_DROP_PERSON_ID", OracleDBType.Decimal, Paremeter.Direction.Input);
param.Value = dropPersonID;
cm.ExecuteNonQuery();
IdentityConfirmed ViewModel控制器
[httpPost]
public ActionResult IdentityConfirmed(FormCollection collection)
{
Guid request = new Guid(collection["ciGUID"]);
dsSession.SECURE_REQUESTSRow secureRequest;
using (OracleConnection cn = new OracleConnection (OracleConnectionManager.GetProxyServiceConnetionString()))
{
cn.Open();
using (OracleTransaction trans = cn.BeginTransaction())
{
using (Data.dsSessionTableAdapters.SECURE_REQUESTSTableAdapter ta = new Data.dsSessionTableAdapters.SECURE_REQUESTSTableAdapter();
{
typedDatasetFiller.ApplyConnection(ta, cn);
secureRequest = ta.GetDataBySecureGUID(request.ToByteArray())[0];
}
decimal KeepPersonID = SessionManager.PersonIdentity.PERSON_ID;
decimal dropPersonID = secureRequest.REQUESTER_PERSON_ID;
Support.MergeAuthIDs(trans, KeepPersonID, dropPersonID);
trans.Commit();
}
}
retrun View("IdentityConfirmed", vm);
}
答案 0 :(得分:0)
它希望是一个字符串。检查数据库中的列类型并将其更改为十进制。
答案 1 :(得分:0)
这是答案,我忘了将变量dropPersonID设置为正确的值。
using (Data.dsSessionTableAdapters.SECURE_REQUESTSTableAdapter ta = new Data.dsSessionTableAdapters.SECURE_REQUESTSTableAdapter();
{
typedDatasetFiller.ApplyConnection(ta, cn);
secureRequest = ta.GetDataBySecureGUID(request.ToByteArray())[0];
}
decimal KeepPersonID = SessionManager.PersonIdentity.PERSON_ID;
decimal dropPersonID = secureRequest.REQUESTER_PERSON_ID;
Support.MergeAuthIDs(trans, KeepPersonID, dropPersonID);