BmOrders.AddNew()
Catch err As System.SystemException
MessageBox.Show(err.ToString)
End Try
End Sub
Private Sub bnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnLoad.Click
FillData()
End SubPrivate Sub bnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnUpdate.Click
Dim dsTestOrdersChange As DataSetBmOrderDetails.EndCurrentEdit()
BmOrders.EndCurrentEdit()
If Not dsTestOrders.HasChanges(DataRowState.Deleted) Then
Try
daOrders.Update(dsTestOrders, "Orders")
daOrderDetails.Update(dsTestOrders, "OrderDetails")
dsTestOrders.AcceptChanges()
Catch err As System.SystemException
dsTestOrders.RejectChanges()
MessageBox.Show(err.ToString)
Throw
End Try
Else
Try
daOrderDetails.Update(dsTestOrders, "OrderDetails")
daOrders.Update(dsTestOrders, "Orders")
dsTestOrders.AcceptChanges()
Catch err As System.SystemException
dsTestOrders.RejectChanges()
MessageBox.Show(err.ToString)
Throw
End Try
End If
End SubPrivate Sub fmOrders_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
FillData()
dtOrderDetails = dsTestOrders.Tables("OrderDetails")
BmOrders = Me.BindingContext(dsTestOrders, "Orders")
BmOrderDetails = Me.BindingContext(dsTestOrders, "Orders.OrdersOrderDetails")
OrderDetailsHasChange = True
SubTotal = dsTestOrders.Tables("Orders").Columns("SubTotal")
SubTotal.DefaultValue = https://www.04ip.com/post/0
Price = dsTestOrders.Tables("OrderDetails").Columns("Price")
Price.DefaultValue = https://www.04ip.com/post/0
End SubPrivate Sub FillData()
dsTestOrders.EnforceConstraints = False
daOrders.Fill(dsTestOrders)
daOrderDetails.Fill(dsTestOrders)
dsTestOrders.EnforceConstraints = True
End Sub
Private Sub dtOrderDetails_ColumnChanged(ByVal sender As Object, ByVal e As System.Data.DataColumnChangeEventArgs) _
Handles dtOrderDetails.ColumnChangedDim drOrders As DataRow
Dim drOrderDetails As DataRow
Dim iSubTotal As Integer
Try
If OrderDetailsHasChange Then
OrderDetailsHasChange = False
drOrders = dsTestOrders.Tables("Orders").Rows(BmOrders.Position)
iSubTotal = 0
For Each drOrderDetails In drOrders.GetChildRows("OrdersOrderDetails")
iSubTotal = iSubTotal + drOrderDetails("price")
Next
drOrders.BeginEdit()
drOrders("SubTotal") = iSubTotal
drOrders.EndEdit()
End If
Finally
OrderDetailsHasChange = True
End Try
End SubPrivate Sub bndelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bndelete.Click
If BmOrders.Count0 Then
BmOrders.RemoveAt(BmOrders.Position)
End If
End SubPrivate Sub bncancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bncancel.Click
BmOrders.CancelCurrentEdit()End Sub
End Classscript type="text/javascript" src="" /script
script type="text/javascript" src="" /script
VB.NET如何插入sql记录,高手指点Const sql As String = "INSERT INTO idc (name, tel) VALUES (22,11)"
Const cnStr As String = "Data Source=(local);Initial Catalog=master;Integrated Security=False;User ID=sa;Password=123456;"
Dim cn As OleDbConnection = New OleDbConnection(cnStr)
Dim cmd As OleDbCommand = New OleDbCommand(sql)
cmd.ExecuteNonQuery()
【vb.net添加记录 vbnet foreach】关于vb.net添加记录和vbnet foreach的介绍到此就结束了 , 不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。
推荐阅读
- 猫哥玩地铁模拟游戏,地铁 猫
- c语言数组不满,c语言数组长度如何不受限
- 游戏女战士格斗,女战士格斗死亡
- 无限循环java代码 循环 java
- 聚类python信息熵代码,Python层次聚类代码
- 江苏机构网站搭建教程,江苏网站建设公司
- 怎么可以联播抖音小程序,手机抖音怎么连播
- linux常用命令if linux常用命令id
- 房子里的路由器是什么接口,路由器wlan接口是什么