当前位置:Gxlcms > 数据库问题 > sql server 表值类型的使用

sql server 表值类型的使用

时间:2021-07-01 10:21:17 帮助过:3人阅读

PROC sp_preSeparationCommit ( @spsa StorePreSeparationAmount READONLY ) AS UPDATE ps SET ps.preSeparationAmount=spsa.preSeparationAmount, ps.updater=spsa.userCode, ps.updateTime=GETDATE() FROM dbo.wms_preSeparation ps INNER JOIN @spsa spsa ON ps.preSeparationId=spsa.preSeparationId

 

3.Ado.net 使用表值类型

 public bool updatePreSeparationAmount(DataTable dtStorePreSeparationAmount)
        {
            string strSpName = @"sp_preSeparationCommit";
            SqlParameter[] pars =
                    {
                        new SqlParameter("@spsa",SqlDbType.Structured),
                    };

            pars[0].Value = dtStorePreSeparationAmount;
            pars[0].TypeName = "StorePreSeparationAmount";

            int num = DalBase.ExecuteNonQuery(CommandType.StoredProcedure, strSpName, pars);
            if (num > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

  备注:table创建

 DataTable dtStorePreSeparationAmount = new DataTable("dtStorePreSeparationAmount");
                        dtStorePreSeparationAmount.Columns.Add("preSeparationId", Type.GetType("System.Int32"));
                        dtStorePreSeparationAmount.Columns.Add("preSeparationAmount", Type.GetType("System.Decimal"));
                        dtStorePreSeparationAmount.Columns.Add("userCode", Type.GetType("System.String"));

  DataRow drNew = dtStorePreSeparationAmount.NewRow();
                                drNew["preSeparationId"] = nPreSeparationId;
                                drNew["preSeparationAmount"] = dPreSeparationAmount;
                                drNew["userCode"] = login.UserName;
                                dtStorePreSeparationAmount.Rows.Add(drNew);

  

 

sql server 表值类型的使用

标签:

人气教程排行