Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 169
  • Last Modified:

Grid Development

Hi all

Ok heres my query...

I have a grid which i use to display data extracted from a database.
I want this grid to be editable, but want that the changes are made in the database only when i press the command button "Save"

However, currently I am facing the problem, that even if i Press Cancel, any changes made in the grid are saved to the database. Can I prevent this dynamic save in any way????

Pls help.


THx
Megha
0
megha
Asked:
megha
1 Solution
 
meghaAuthor Commented:
my current code is this:

Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub Form_Load()

Call Open_rneVersionCtrl

Set dbgProdVersCtrl.DataSource = frmLogin.rneVersionCtrl

dbgProdVersCtrl.Columns(0).Locked = True
dbgProdVersCtrl.Columns(1).Locked = True

End Sub

Public Sub Open_rneVersionCtrl()

'close record set if it is open
If frmLogin.rneVersionCtrl.State = adStateOpen Then frmLogin.rneVersionCtrl.Close

frmLogin.rneVersionCtrl.CursorLocation = adUseClient 'set the CursorLoccation for rneUser

frmLogin.rneVersionCtrl.Open "SELECT Proj_Prod_Relation.product, Version_Control.* FROM Proj_Prod_Relation, Version_Control WHERE Version_Control.projPRodID = Proj_Prod_Relation.projProdID AND Proj_Prod_Relation.customerID = '" & custIDSelected & "' AND Proj_Prod_Relation.projectID = '" & projectIDSelected & "'", frmLogin.cneSupport, adOpenStatic, adLockOptimistic

End Sub

Hope this helps....
0
 
supunrCommented:
why not use trasactions.

e.g.

Private Commit as boolean
Private conn as ADODB.Connection

Private Sub Form_Load()
   Commit = false
   ' Open the connection
   Set conn = new ADODB.Connection
   conn.Open "<your connection string>"
   ' begin trasaction
   conn.BeginTrans
End Sub

Private cmdOK_Click()
    Commit = true
    Unload Me
ENd Sub

Private cmdCancel_Click()
    Unload Me
ENd Sub

Private Sub Form_Unload()
    If (conn.State = adStateOpen) then
        if (Commit) then
            conn.CommitTrans  ' save changes
        else
            conn.RollbackTrans 'undo changes
        End if
        conn.close
        set conn = nothing
    end if
End Sub
0
 
meghaAuthor Commented:
Hi thx
will try and get back to u on the result
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
inthedarkCommented:
The other way is to use a disconnected record set.  Or disconnected the recordset after you read but before you display the data.
0
 
meghaAuthor Commented:
hi i tried using cancel update and that worked..

but thx for yur help.. transactions was giving me some problem

0
 
MindphaserCommented:
Points refunded and moved to PAQ

** Mindphaser - Community Support Moderator **
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now