VladimirKim
Programmer
Hi, here is the code:
Public Function convertToRS(ByVal ds As DataSet) As Recordset
Dim rs As DAO.Recordset
Dim i, j As Integer
Dim dt As New TableDef
For i = 0 To ds.Tables(0).Columns.Count - 1
dt.CreateField(ds.Tables(0).Columns(i).ColumnName)
Next
For i = 0 To ds.Tables(0).Rows.Count - 1
rs = dt.OpenRecordset()
rs.AddNew()
For j = 0 To ds.Tables(0).Columns.Count - 1
rs(j).Value = ds.Tables(0).Rows(i)(j)
Next
rs.Update()
Next
Return rs
End Function
It gives me an error on rs=dt.OpenRecordset().
It says object invalid or no longer set.
My initial goal to convert dataset into a DAO recordset. There is only one table in the dataset.
Public Function convertToRS(ByVal ds As DataSet) As Recordset
Dim rs As DAO.Recordset
Dim i, j As Integer
Dim dt As New TableDef
For i = 0 To ds.Tables(0).Columns.Count - 1
dt.CreateField(ds.Tables(0).Columns(i).ColumnName)
Next
For i = 0 To ds.Tables(0).Rows.Count - 1
rs = dt.OpenRecordset()
rs.AddNew()
For j = 0 To ds.Tables(0).Columns.Count - 1
rs(j).Value = ds.Tables(0).Rows(i)(j)
Next
rs.Update()
Next
Return rs
End Function
It gives me an error on rs=dt.OpenRecordset().
It says object invalid or no longer set.
My initial goal to convert dataset into a DAO recordset. There is only one table in the dataset.