VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This code will allow you to save from a flex grid to an Access 2000 database using ADO.

by Matt (8 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 4th December 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This code will allow you to save from a flex grid to an Access 2000 database using ADO.

Rate This code will allow you to save from a flex grid to an Access 2000 database using ADO.



    Dim i As Integer 
    Dim query As String
    Dim cnNew As ADODB.Connection 'Connection
         Set cnNew = New ADODB.Connection 
          cnNew.ConnectionString = "Provider=Microsoft.jet.OLEDB.4.0; " & _
                        "Data Source =C:\YourDatabase.mdb"
           cnNew.Open
                       
     Set rsUpdate = New ADODB.Recordset
                query = "SELECT * from history"
      rsUpdate.Open query, cnNew, adOpenStatic, adLockOptimistic
                
    For j = 1 To 100    'This is the number of rows to go through it can be whatever number you like
        Fg2.RowPosition(j) = j 'go to the next row
            For i = 0 To 3 'go to the next column. This is the number of columns in the grid. It can be whatever number you like.
                Select Case i  'Make sure we get to the right column
                   Case Is = 0  'evaluate the current column
                        Fg2.ColPosition(i) = i 'go to the next column 
                        rsUpdate!DATE1 = Fg2.TextMatrix(j, i)   'Save the first column's record
                    Case Is = 1
                         Fg2.ColPosition(i) = i 'go to the next column
                         rsUpdate!WHO! = Fg2.TextMatrix(j, i)  'Save the second column's record
                     Case Is = 2
                         Fg2.ColPosition(i) = i 'go to the next column
                         rsUpdate!ITEM1 = Fg2.TextMatrix(j, i)   'Save the third column's record
                     Case Is = 3
                         Fg2.ColPosition(i) = i 'go to the next column
                         rsUpdate!DESCRIPTION1 = Fg2.TextMatrix(j, i)  'Save the fourth column's record
                    End Select
             Next i 'go to the next column
                                        If rsUpdate.EOF = True Then 'if EOF Exit
                                            Else
                                                If j = 100 Then 'Exit so we don't try to save more than 100 records
                                                Else
    rsUpdate.Update  'update the current recordset
                                                    rsUpdate.MoveNext 'move to the next record
                                             End If
                                       End If
  Next j ' go to the next row
  Fg2.Visible = True 'Lets turn the grid back on so we can see it.

Download this snippet    Add to My Saved Code

This code will allow you to save from a flex grid to an Access 2000 database using ADO. Comments

No comments have been posted about This code will allow you to save from a flex grid to an Access 2000 database using ADO.. Why not be the first to post a comment about This code will allow you to save from a flex grid to an Access 2000 database using ADO..

Post your comment

Subject:
Message:
0/1000 characters