100% found this document useful (4 votes)
6K views2 pages

Convert DataTable To RecordSet

This function converts a DataTable object to an ADODB Recordset object. It iterates through the columns of the DataTable, appending the column names and data types to the Recordset. It then iterates through the rows of the DataTable, adding the row data to the Recordset. Finally, it returns the populated Recordset. A secondary function translates .NET data types to ADODB data types.

Uploaded by

Muneeb Khan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
6K views2 pages

Convert DataTable To RecordSet

This function converts a DataTable object to an ADODB Recordset object. It iterates through the columns of the DataTable, appending the column names and data types to the Recordset. It then iterates through the rows of the DataTable, adding the row data to the Recordset. Finally, it returns the populated Recordset. A secondary function translates .NET data types to ADODB data types.

Uploaded by

Muneeb Khan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Public Function convertToADODB(ByRef table As DataTable) As ADODB.

Recordset
'Try
Dim result As New [Link]

[Link] = [Link]

Dim resultFields As [Link] = [Link]

Dim col As DataColumn

For Each col In [Link]


[Link]([Link], TranslateType([Link]),
[Link], [Link] = [Link])

Next

[Link]([Link],
[Link], [Link], 0)

For Each row As DataRow In [Link]

[Link]([Link],
[Link])

For i As Integer = 0 To [Link]


resultFields(i).Value = row(i)
Next
Next
Return result
'Catch ex As Exception

'End Try

End Function

Public Function TranslateType(ByRef type As Type) As [Link]


Try
Select Case [Link]

Case "[Link]"
Return [Link]

Case "[Link]"
Return [Link]

Case "[Link]"
Return [Link]

Case "[Link]"
Return [Link]

Case "[Link]"
Return [Link]

Case "[Link]"
Return [Link]

Case "System.Int16"
Return [Link]

Case "System.Int32"
Return [Link]

Case "System.Int64"
Return [Link]

Case "[Link]"
Return [Link]

Case "[Link]"
Return [Link]

Case "System.UInt16"
Return [Link]

Case "System.UInt32"
Return [Link]

Case "System.UInt64"
Return [Link]

Case "[Link]"
'case default
Return [Link]

End Select

Catch ex As Exception
MsgBox([Link])
End Try

End Function

You might also like