VB6 DataGrid Control :- Populating Editing and saving data back to Oracle-VBForums
Results 1 to 4 of 4

Thread: VB6 DataGrid Control :- Populating Editing and saving data back to Oracle

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2010
    Posts
    41

    Red face VB6 DataGrid Control :- Populating Editing and saving data back to Oracle

    Hi All

    I am using VB6 with oracle back ground

    I am able to display the data in the datagrid (microsoft datagrid control 6.0).

    now
    I am required to allow user to edit only third column in the grid(i.e other than 3rd col all are not editable.) and save the edited row back to database.

    I am not getting how to do that. Please help, Please its urgent

    an example code will be a good help

    Thanks in advance

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    19,584

    Re: VB6 DataGrid Control :- Populating Editing and saving data back to Oracle

    an example code will be a good help
    an example of the code you have now, to populate the datagrid, would be a good start for getting help
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2010
    Posts
    41

    Re: VB6 DataGrid Control :- Populating Editing and saving data back to Oracle

    I used following code to fill datagrid


    vb Code:
    1. Public con As ADODB.Connection
    2. Public rs As ADODB.Recordset
    3.  
    4. Set con = New ADODB.Connection
    5. con.Open "Provider=msdaora;Data Source=database;User Id=uid;Password=pwd;"
    6.  
    7.  
    8.  
    9.  
    10. Set rs = New ADODB.Recordset
    11. strSQL = "SELECT * FROM table_name"
    12. rs.CursorType = adOpenStatic
    13. rs.CursorLocation = adUseClient
    14. rs.LockType = adLockOptimistic
    15.  
    16. rs.Open strSQL, con, , , adCmdText
    17.  
    18.    
    19.  
    20.     If rs.RecordCount > 0 Then
    21.       Set DataGrid1.DataSource = rs
    22.      
    23.     Else
    24.         MsgBox "No Record Found. Please Check  "
    25.        rs.Close
    26.  
    27. End If


    with this code i m able to get data in datagrid.

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    19,584

    Re: VB6 DataGrid Control :- Populating Editing and saving data back to Oracle

    if you edit a row in the datagrid, you would need to find the correct record in the recordset (rs) and then edit that record, change the value of the appropriate field then update

    either declare rs at global level and leave open, close when closing program, or keep opening recordset each time
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.