VB.NET中使用Linq TO SQL添加数据后获得自增长列ID:

 

               Dim tempOrdre As New Order With {
                    .CustomerID = cmbCustomerName.SelectedValue.ToString,
                    .ProductID = cmbProductSpec.SelectedValue.ToString,
                    .ProductNumber = txtProductNumber.Text.Trim,
                    .BatchNO = txtBatchNO.Text.Trim,
                    .OrderDate = dtpOrderDate.Value.ToShortDateString
                    }

                db.Order.InsertOnSubmit(tempOrdre)

                Try
                    db.SubmitChanges() ’提交数据库操作
                    Dim intid As Integer = tempOrdre.OrderID ‘获得自增长列ID
                    MessageBox.Show(intid) ’显示ID
                Catch ex As Exception
                    Throw New System.Exception(ex.Message, ex.InnerException)
                End Try

 

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-29
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案