Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

DataTable to MSAccess table object

$
0
0

Hi,

I have a datatable in VB.net and i want to dump this table in MSAccess as new table.

How can i achieve this.... i need to do this from code only

Following is code snippet

                        Dim TableAdapter As New OleDb.OleDbDataAdapter("SELECT * FROM Test", con)
                        Try
                            dtTable = New DataTable

                            TableAdapter.Fill(dtTable) ' Fill the data table

                            'Update the EUID column values with description
                            For Each column As DataColumn In dtTable.Columns
                                If column.ColumnName.Contains("EUID") Then
                                    'Update each value with description
                                    For i As Integer = 1 To dtTable.Rows.Count - 1
                                        'get the description of the
                                        dicEngg.TryGetValue(IIf(dtTable.Rows(i).Item(column.ColumnName) = " ", 0, dtTable.Rows(i).Item(column.ColumnName)), strValue)
                                        If strValue Is Nothing Then
                                            dtTable.Rows(i).Item(column.ColumnName) = ""
                                        Else
                                            dtTable.Rows(i).Item(column.ColumnName) = strValue.Trim()
                                        End If
                                    Next
                                End If
                            Next
                            ' Create a new table in MSAccess

                            'Create table in MSaccess using "dtTable" datatable object

                            dtTable.Clear()
                            dtTable.Dispose()


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>