Hi i am trying to read from a text file and enter this into a table.The text file contains just 3 didget numbers sepearted by a line to distingues a new number. The table consists of 2 columns called ID (which is auto increment PK) and ISBN. The table is called IntTable in a database called book.mdf. I have found some code which i need to change to accumplish this task.Can someone direct me as to what i should be trying to change,add etc i would be very greatful. I am extremly new to all of VB,ASP and using Visual Studio 2010 so please bare with me if i ask what you may percieve as silly questions. Thanks in advance. Below is the code which i presume needs changing
Code:
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
Dim tbl As New DataTable("mytable")
tbl.Columns.Add("col1", GetType(String))
Dim sFilename As String = "C:\Users\User\Desktop\test.txt"
Dim myStream As System.IO.StreamReader = New System.IO.StreamReader(sFilename)
Dim line As String
Dim aRow As DataRow
Do
line = myStream.ReadLine()
MsgBox(line)
If line Is Nothing Then
Exit Do
End If
Dim sAry As String() = Split (line, ";")
aRow = tbl.NewRow
aRow(0) = sAry(0)
tbl.Rows.Add(aRow)
Loop
myStream.Close()
For Each aRow In tbl.Rows
Console.WriteLine("{0}", aRow(0))
Next
End Sub
End Class
Comment