Trasaction and Dataset



hello i would like to know a information
i've a form made to insert a new record in my database
the ID is calculated as a result of max of existing record and than add by
one
(but in this ID there are other data is not a simple counter)

is possible to create a transaction that look a table from the calculation
of maxID to save of record ?


here is my code without trasaction:

Try
Dim r As System.Data.DataRowView
r = Me.RiparazioniBindingSource.Current
Dim cmd As New OleDb.OleDbCommand
cmd.Connection = My.Application.db.Connection
'here i calulate the max of ID

cmd.CommandText = "SELECT MAX(IDRiparazione) from [Riparazioni]"
Dim MaxIDRiparazione As Integer
Try
MaxIDRiparazione = cmd.ExecuteScalar()
Catch ex As Exception
MaxIDRiparazione = 0
End Try

' here is the proc where i calculate the next

r("IDRiparazione") = Format(MaxIDRiparazione + 1, "00000000")

' here i save the data from dataset
Me.Validate()
Me.RiparazioniBindingSource.EndEdit()
Me.RiparazioniTableAdapter.Update(Me.DbDataSet.Riparazioni)

' other dataset to save data
Me.ClientiBindingSource.EndEdit()
Me.ClientiTableAdapter.Update(Me.DbDataSet1.Clienti)

' now i close the form
Me.Close()

' here is my message to say ALL OK
MsgBox("Riparazione salvata con successo", MsgBoxStyle.Information)
Catch ex As Exception
MsgBox("Errore nel salvataggio della riparazione." & vbCrLf & ex.Message,
MsgBoxStyle.Critical)
End Try


excuse me by my previous post in italian
thanks in advance

FLAVIO


.



Relevant Pages

  • Trasaction and dataset
    ... is possible to create a transaction that look a table from the calculation ... Dim cmd As New OleDb.OleDbCommand ... Dim MaxIDRiparazione As Integer ... Catch ex As Exception ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Deleting rows based on data NOT meeting criteria --working mac
    ... The last row (lstRw) is calculated in the code you are using based ... Dim lstRw ... ..Calculation = xlCalculationManual ... Blank Cell ...
    (microsoft.public.excel.programming)
  • Re: how to combine several files, all with same columns, into one
    ... Dim myCalc As XlCalculation ... .Calculation = xlCalculationManual ... workbook, and all 100 files are in one folder. ...
    (microsoft.public.excel.misc)
  • Re: VBA Equivelent of CalculateOnExit
    ... The formfield calculation fields ... and a calculation formfield in column 4 "SubTotal" with a formula ... Dim pTable As Word.Table ... Dim lngVarPosit As Long ...
    (microsoft.public.word.vba.general)
  • Re: Calculations in SQL
    ... Now that I see the full calculation, ... Dim curOneFif As Currency ... Dim intSumPop As Long ... Sylvain Lafontaine, ing. ...
    (microsoft.public.access.adp.sqlserver)