Dim tbl As New DataTable("mytable")
tbl.Columns.Add("col1", GetType(String))
tbl.Columns.Add("col2", GetType(String))
tbl.Columns.Add("col3", GetType(Integer))
Dim sFilename As String = Server.MapPath("somedata.txt")
Dim myStream As System.IO.StreamReader = New System.IO.StreamReader(sFilename)
Dim line As String
Dim aRow As DataRow
Do
line = myStream.ReadLine()
If line Is Nothing Then
Exit Do
End If
Dim sAry As String() = Split(line, ";")
aRow = tbl.NewRow
aRow(0) = sAry(0)
aRow(1) = sAry(1)
aRow(2) = CInt(sAry(2))
tbl.Rows.Add(aRow)
Loop
Dim dt As New DataTable
Dim dr As DataRow
'*** Column ***'
dt.Columns.Add("CustomerID")
dt.Columns.Add("Name")
dt.Columns.Add("Email")
dt.Columns.Add("CountryCode")
dt.Columns.Add("Budget")
dt.Columns.Add("Used")
Dim StrWer As StreamReader
Dim readLine As String
StrWer = File.OpenText(Server.MapPath("thaicreate.txt"))
Do Until StrWer.EndOfStream
readLine = StrWer.ReadLine()
'*** Rows ***'
dr = dt.NewRow
dr("CustomerID") = Split(readLine,",")(0)
dr("Name") = Split(readLine,",")(1)
dr("Email") = Split(readLine,",")(2)
dr("CountryCode") = Split(readLine,",")(3)
dr("Budget") = Split(readLine,",")(4)
dr("Used") = Split(readLine,",")(5)
dt.Rows.Add(dr)
Loop
StrWer.Close()