3
Answers

How do i save an new datatable to a Access database.

Borat

Borat

15y
6.9k
1

Hopefully someone can help me with this problem.

 

I create in runtime an datatable and i want to save it to my Access database.

The code i got at this moment is:

Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    _dtDatum = Now

    Try
      _oDt = New DataTable("t" & _
                           _dtDatum.Year & _
                           _dtDatum.Month.ToString("d2") & _
                           _dtDatum.Day.ToString("d2"))
      _oDt.Columns.Add(New DataColumn("Kolom_1", Type.GetType("System.String")))
      _oDt.Columns.Add(New DataColumn("Kolom_2", Type.GetType("System.String")))
      _oDt.Columns.Add(New DataColumn("Kolom_3", Type.GetType("System.String")))

      For i As Integer = 0 To 5 Step 1
        _Odr = _oDt.NewRow
        _Odr("Kolom_1") = "Kolom " & i.ToString
        _Odr("Kolom_2") = "Kolom " & (i + 1).ToString
        _Odr("Kolom_3") = DateTime.Now

        _oDt.Rows.Add(_Odr)
      Next

      For Each o As DataColumn In _oDt.Columns
        clbColums.Items.Add(o.ToString)
      Next
    Catch ex As Exception
      MsgBox(ex.Message)
    Finally

    End Try
  End Sub

But i can't find a way to save this to the database.

 

Thanks for helping.

Answers (3)