如何在数据层中使用多个SP进行插入和更新 [英] How to use more than one SP in datalayer for insert and Update

查看:222
本文介绍了如何在数据层中使用多个SP进行插入和更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public void Update(List<businessobjects.tables.item> paramItemDetailCollection)
        {
            string spName = "spupdateItem";
            Database db = DatabaseFactory.CreateDatabase(ConnectionString);
            foreach (FiesSaaS.BusinessObjects.Tables.Item ObjaItem in paramaItemDetailCollection)
            {
                DbCommand dbCommand = db.GetStoredProcCommand(spName);
                db.AddInParameter(dbCommand, "@ItemID", DbType.String, ObjItemDetail.ItemID);
                db.AddInParameter(dbCommand, "@PTypeID", DbType.String, ObjItemDetail.TypeID);
                db.AddInParameter(dbCommand, "@SlNo", DbType.String, ObjItemDetail.SlNo);
                db.AddInParameter(dbCommand, "@BarCode", DbType.String, ObjItemDetail.BarCode);               
                db.ExecuteScalar(dbCommand);
            }



我需要在上面的类public void update(...){}中为插入细节添加一个sp。

sp名称是spinsertitem。


I need to add one more sp for insert details in the above class public void update(...){}.
sp name is spinsertitem.

推荐答案

你可以在那个storeprocedure中执行另一个storeprocedure

http://stackoverflow.com/questions/8858620/calling-stored-procedure-from-another-stored -procedure-sql-server [ ^ ]
you may execute Another storeprocedure in that storeprocedure
http://stackoverflow.com/questions/8858620/calling-stored-procedure-from-another-stored-procedure-sql-server[^]


这篇关于如何在数据层中使用多个SP进行插入和更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆