How to fill Datatable from Notepad file

  • Dim dt As New DataTable()

      Dim col As New DataColumn("Name")  ' Add dynamically datatable colum name
    Dim col2 As New DataColumn("abc")

      col.DataType = System.Type.GetType("System.String")  ' Define the type of columns in datatable

      Dim aa() As String = File.ReadAllLines("D:\a.txt")

    For Each item As String In aa
    Dim dr As DataRow = dt.NewRow()

    dr(0) = item.ToString()



    DataGridView1.DataSource = dt

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week