Help with VB6 ADO Recordset (Resolved on My Own)
Can Anyone help me with a Database Project. I'm trying to Update an existing recordset with records from another recordset that has been saved as a "*.rec" file.
I have so far been able to open the Saved Recordset, and the Target Recordset but all my attempt to update the Target Recordset with the Field Values from the Saved Recordset have Failed. Any Help Please I'm begging you....
'Read the Saved Record
Set MyCn = New ADODB.Connection
Set myrs = New ADODB.Recordset
MyStrfile = txtFile.Text & LstFiles.Text
myrs.Open App.Path & "\Reports\" & LstFiles.Text & "", , , adLockBatchOptimistic, adCmdFile
'Assign the Saved Records to a Data Grid
TDBGrid1.DataSource = myrs
'Update the Grid with The Saved Information
TDBGrid1.Update
'Read the Database Connection String to the Students Table
UpdateCon
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cnstr = Conn
On Error Resume Next
Program = TxtProg.Text
sSqlStr = "SELECT * FROM Students"
cn.Open cnstr
rs.CursorLocation = adUseClient
rs.CursorType = adOpenStatic
rs.Open sSqlStr, cn
'Get the Original Number of Records
TotalRecords = rs.RecordCount
MyTotalRecs = myrs.RecordCount
'Position the Records to the Place to be
myrs.MoveFirst
'Get the Values from the Saved "*.Rec" file
Values = myrs.GetRows([MyTotalRecs], [adBookmarkFirst], _
Array("Program", "Position", "CDC", "First", "Last", "Facility", _
"Building", "Bed", "BedLtr", "Ethnic", "DateIn", "Status", "Title", _
"Pay", "DucatDate", "DucatTime", "DucatLoc", "Entry", "Pre", "Post", _
"Week", "TransDate", "DateOut", "Tabe"))
For recIndex = 0 To UBound(Values, 2)
For fldIndex = 0 To UBound(Values)
Print Values(fldIndex, recIndex),
Next
rs.MoveLast
If rs.Supports(adAddNew) Then
rs.AddNew
rs.Update Values
End If
Next
'Update the Master Table with the Records
Me.TDBGrid1.DataSource = myrs ' Saved Record
Me.TDBGrid2.DataSource = rs ' New Recordset
'Update the Grid with New Students
Me.TDBGrid2.Update
'Me.TDBGrid2.Update
Msg = "Database Updated with " & MyTotalRecs & " New Records from " & TxtProg.Text & " ,Total Records Now = " & TotalRecords + MyTotalRecs
Beep
Me.StatusBar1.Panels(1).Text = " " & Msg
Set myrs = Nothing
Set rs = Nothing
Here is what I have so far I do not get any errors but I also do not get any Information in the 2nd grid either. I'm only a hobbist so my knowledge is limited,, go easy on me..