For the moment I just use the streamreader in CF20 and read data in line by line, and use 2 nested do loop's to break the delimited data down into an array. Then I use a Sql statement to Insert the data into the SqlCe database.
It may not be XML, but it works for now. So I will mark this thread resolved.
Accounts.txt contains some data such as:
Code:000100|101 Any Street|1|1 000200|310 My Street|1|2 etc etc
Thanks.Code:Dim sr As StreamReader = File.OpenText("\My Documents\Accounts.txt") Dim strLine As String Dim strData(0 To 3) As String Dim intStart As Integer Dim intLength As Integer Dim intCount As Integer Dim intFieldCount As Integer Dim strSql As String Dim ssceconn As New SqlCeConnection("Data Source = \My Documents\data.sdf") ssceconn.Open() Dim sqlInsertRow As SqlCeCommand = ssceconn.CreateCommand() Dim table As DataTable = New DataTable intCount = 0 Do intFieldCount = 0 intStart = 1 strLine = sr.ReadLine() Do intLength = InStr(intStart, strLine, "|") If intLength <> 0 Then strData(intFieldCount) = Mid(strLine, intStart, intLength - intStart) Else strData(intFieldCount) = Mid(strLine, intStart, (Len(strLine) - intStart) + 1) End If intStart = intLength + 1 intFieldCount = intFieldCount + 1 Loop Until intLength = 0 strSql = "INSERT INTO Accounts([Account No], [Address], [Var 1], [Var 2]) VALUES" strSql = strSql & " ('" & strData(0) & "', '" & strData(1) & "'," & strData(2) & "," & strData(3) & ");" sqlInsertRow.CommandText = strSql sqlInsertRow.ExecuteNonQuery() intCount = intCount + 1 Loop Until sr.EndOfStream ssceconn.Close()




Reply With Quote