自定义DataAdapter批量更新

 < WebMethod ()>   Public   Function   AddMemCard( ByVal   ds   As   DataSet   )   As   String
          Dim   con   As   New   SqlConnection
        con.ConnectionString =   ConfigurationManager .ConnectionStrings( "wingsbook"   ).ToString()
          Dim   cmd   As   New   SqlCommand
          Dim   da   As   New   SqlDataAdapter
          Try
            con.Open()
            cmd.Connection = con
            cmd.CommandText =   "Insert into WBMemCard(MemCardId,MemCardMoney,MemCardBuyMan,MemCardRegisterId,MemCardName,"   & _
                                "MemCardPhone,MemCardMobile,MemCardMail,MemCardAdress,MemCardSTime,MemCardSNname) values("   & _
                                "@MemCardId,@MemCardMoney,@MemCardBuyMan,@MemCardRegisterId,@MemCardName,"   & _
                                "@MemCardPhone,@MemCardMobile,@MemCardMail,@MemCardAdress,getdate(),@MemCardSNname)"
            da.InsertCommand = cmd
            cmd.Parameters.Add(   New   SqlParameter   ( "@MemCardId" ,   SqlDbType .NVarChar, 50))
            cmd.Parameters.Add(   New   SqlParameter   ( "@MemCardMoney" ,   SqlDbType .Decimal))
            cmd.Parameters.Add(   New   SqlParameter   ( "@MemCardBuyMan" ,   SqlDbType .NVarChar, 50))
            cmd.Parameters.Add(   New   SqlParameter   ( "@MemCardRegisterId" ,   SqlDbType .Int))
            cmd.Parameters.Add(   New   SqlParameter   ( "@MemCardName" ,   SqlDbType .NVarChar, 50))
            cmd.Parameters.Add(   New   SqlParameter   ( "@MemCardPhone" ,   SqlDbType .NVarChar, 20))
            cmd.Parameters.Add(   New   SqlParameter   ( "@MemCardMobile" ,   SqlDbType .NVarChar, 20))
            cmd.Parameters.Add(   New   SqlParameter   ( "@MemCardMail" ,   SqlDbType .NVarChar, 100))
            cmd.Parameters.Add(   New   SqlParameter   ( "@MemCardAdress" ,   SqlDbType .NVarChar, 100))
            cmd.Parameters.Add(   New   SqlParameter   ( "@MemCardSNname" ,   SqlDbType .NVarChar, 50))
            cmd.Parameters(0).SourceColumn =   "MemCardId"
            cmd.Parameters(0).SourceVersion =   DataRowVersion .Original
            cmd.Parameters(1).SourceColumn =   "MemCardMoney"
            cmd.Parameters(1).SourceVersion =   DataRowVersion .Original
            cmd.Parameters(2).SourceColumn =   "MemCardBuyMan"
            cmd.Parameters(2).SourceVersion =   DataRowVersion .Original
            cmd.Parameters(3).SourceColumn =   "MemCardRegisterId"
            cmd.Parameters(3).SourceVersion =   DataRowVersion .Original
            cmd.Parameters(4).SourceColumn =   "MemCardName"
            cmd.Parameters(4).SourceVersion =   DataRowVersion .Original
            cmd.Parameters(5).SourceColumn =   "MemCardPhone"
            cmd.Parameters(5).SourceVersion =   DataRowVersion .Original
            cmd.Parameters(6).SourceColumn =   "MemCardMobile"
            cmd.Parameters(6).SourceVersion =   DataRowVersion .Original
            cmd.Parameters(7).SourceColumn =   "MemCardMail"
            cmd.Parameters(7).SourceVersion =   DataRowVersion .Original
            cmd.Parameters(8).SourceColumn =   "MemCardAdress"
            cmd.Parameters(8).SourceVersion =   DataRowVersion .Original
            cmd.Parameters(9).SourceColumn =   "MemCardSNname"
            cmd.Parameters(9).SourceVersion =   DataRowVersion .Original
            da.Update(ds,   "MemCard" )
            ds.Dispose()
            cmd.Dispose()
            con.Close()
            con.Dispose()
              Return   "OK"
          Catch   ex   As   Exception
              Return   ex.Message
          End   Try

      End   Function
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值