EDN Admin
Well-known member
Hi I have a vb6 code block
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Private <span style="color:Blue; Sub CmdSave_Click()
<span style="color:Blue; On <span style="color:Blue; Error <span style="color:Blue; Goto LblErr
con.BeginTrans
<span style="color:Blue; Set Rs = <span style="color:Blue; New ADODB.Recordset
Rs.Open <span style="color:#A31515; "Select * from Table1 where code=" & Code, con, adOpenKeyset, adLockOptimistic
<span style="color:Blue; If Rs.EOF = <span style="color:Blue; True <span style="color:Blue; Then
Rs.AddNew
<span style="color:Blue; End <span style="color:Blue; If
Rs!name = name
Rs.Update
<span style="color:Blue; Set Rs = <span style="color:Blue; New ADODB.Recordset
Rs.Open <span style="color:#A31515; "Select * from Table2 where code=" & Code & <span style="color:#A31515; "", con, adOpenKeyset, adLockOptimistic
<span style="color:Blue; If Rs.EOF = <span style="color:Blue; False <span style="color:Blue; Then
con.Execute <span style="color:#A31515; "Delete * from Table2 where code=" & Code & <span style="color:#A31515; ""
<span style="color:Blue; End <span style="color:Blue; If
Rs.AddNew
Rs!Code = Code
Rs!Des = Des
Rs.Update
<span style="color:Blue; If Code <> 0 <span style="color:Blue; Then
con.Execute <span style="color:#A31515; "Delete * from Table3 where code=" & Code
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; Set Rs = <span style="color:Blue; New ADODB.Recordset
Rs.Open <span style="color:#A31515; "Table3", con, adOpenKeyset, adLockOptimistic, adCmdTableDirect
Rs.AddNew
Rs!Code = Code
Rs!Rate = Rate
Rs.Update
con.CommitTrans
<span style="color:Blue; Exit <span style="color:Blue; sub
LblErr:
con.RollbackTrans
<span style="color:Blue; End <span style="color:Blue; Sub
[/code]
<br/>
I want a Vb. net 2010 Code like above Code
Example
I add Or update Table Basis on code variable if code=0 then add data if code<>0 then update data
and if it generate error in middle of code then rollback all transaction
and idont want to use sql command Store Procedure like insert,update, delete.
Please Provide me code Like VB6 (On Exactly But Similer Like that) in vb.net 2010 <hr class="sig Art Of Living Is Art Of Giving
View the full article
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Private <span style="color:Blue; Sub CmdSave_Click()
<span style="color:Blue; On <span style="color:Blue; Error <span style="color:Blue; Goto LblErr
con.BeginTrans
<span style="color:Blue; Set Rs = <span style="color:Blue; New ADODB.Recordset
Rs.Open <span style="color:#A31515; "Select * from Table1 where code=" & Code, con, adOpenKeyset, adLockOptimistic
<span style="color:Blue; If Rs.EOF = <span style="color:Blue; True <span style="color:Blue; Then
Rs.AddNew
<span style="color:Blue; End <span style="color:Blue; If
Rs!name = name
Rs.Update
<span style="color:Blue; Set Rs = <span style="color:Blue; New ADODB.Recordset
Rs.Open <span style="color:#A31515; "Select * from Table2 where code=" & Code & <span style="color:#A31515; "", con, adOpenKeyset, adLockOptimistic
<span style="color:Blue; If Rs.EOF = <span style="color:Blue; False <span style="color:Blue; Then
con.Execute <span style="color:#A31515; "Delete * from Table2 where code=" & Code & <span style="color:#A31515; ""
<span style="color:Blue; End <span style="color:Blue; If
Rs.AddNew
Rs!Code = Code
Rs!Des = Des
Rs.Update
<span style="color:Blue; If Code <> 0 <span style="color:Blue; Then
con.Execute <span style="color:#A31515; "Delete * from Table3 where code=" & Code
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; Set Rs = <span style="color:Blue; New ADODB.Recordset
Rs.Open <span style="color:#A31515; "Table3", con, adOpenKeyset, adLockOptimistic, adCmdTableDirect
Rs.AddNew
Rs!Code = Code
Rs!Rate = Rate
Rs.Update
con.CommitTrans
<span style="color:Blue; Exit <span style="color:Blue; sub
LblErr:
con.RollbackTrans
<span style="color:Blue; End <span style="color:Blue; Sub
[/code]
<br/>
I want a Vb. net 2010 Code like above Code
Example
I add Or update Table Basis on code variable if code=0 then add data if code<>0 then update data
and if it generate error in middle of code then rollback all transaction
and idont want to use sql command Store Procedure like insert,update, delete.
Please Provide me code Like VB6 (On Exactly But Similer Like that) in vb.net 2010 <hr class="sig Art Of Living Is Art Of Giving
View the full article