daz51
New member
I have a problem with a streamreader in visual basic 2008. I am updating a database from text files on an ftp server. The streamreader works fine until the file is more than 100,000 bytes long. It reads until it reaches this point and then just ends. No error message, it just reads to this point which happens to be 2 fields out of 6 in the database stream. My question is - does the streamreader have a limit? And if so what is a workaround?
VB.NET:
Dim connString As String = "Data Source=" & pDataBase
conn = New SqlCeConnection(connString)
Dim strQuery As String = ""
Dim pDate As Date
Dim sDate As String
Try
conn.Open()
Dim sr As New StreamReader("c:\NCPLink\files\" & sFile, Encoding.Default, 32000)
sr.BaseStream.Seek(0, SeekOrigin.Begin)
sCnt = 0
strQuery = "delete from departments"
cmd = New SqlCeCommand(strQuery, conn)
cmd.ExecuteNonQuery()
Do Until sr.EndOfStream
Dim sLine As String = ""
Dim sOut() As String
sLine = sr.ReadLine()
sOut = Split(sLine, ",")
sCnt = sCnt + 1
strQuery = "INSERT INTO [departments](code, description, price, priceoverride, plusgst, extra) "
strQuery = strQuery & "VALUES ('" & Trim(sOut(0)) & "', '" & Trim(sOut(1)) & "', " & Trim(sOut(2)) & ", '" & Trim(sOut(3)) & "', '" & Trim(sOut(4)) & "', '" & Trim(sOut(5)) & "')"
cmd = New SqlCeCommand(strQuery, conn)
cmd.ExecuteNonQuery()
Loop
sr.Close()
Catch ex As SqlCeException
MessageBox.Show(ex.Message)
Finally
conn.Close()
End Try