here is the loop of my vb.net code
Do While (Not stringReader Is Nothing)
Application.DoEvents()
percent = Math.Round(curline * 100.0F / lineCount)
If (String.Compare(lineAbove, "/") = 0) Then
stringReader = fileReader.ReadLine()
curline = curline + 1
currentCategory = stringReader
TestID = TestID + 1
totalTests = totalTests + 1
Else
'INSERT INTO table1
mySqlCommand = New SqlCeCommand("
INSERT INTO table1(q_text, q_mark, q_category, q_test)
VALUES (?, ?, ?, ?)")
mySqlCommand.Connection = conn
'These VALUES
words = stringReader.Split(New Char() {" "c})
mySqlCommand.Parameters.AddWithValue("@q_text", words(0))
mySqlCommand.Parameters.AddWithValue("@q_mark", words(1))
mySqlCommand.Parameters.AddWithValue("@q_category", currentCategory)
mySqlCommand.Parameters.AddWithValue("@q_test", TestID)
'EXECUTE SQL
Try
SQLResult = mySqlCommand.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message())
End Try
lblImport.Text = "Please wait ... " & percent & "%" & "."
TotalQuestions = TotalQuestions + 1
End If
stringReader = fileReader.ReadLine()
curline = curline + 1
lineAbove = stringReader
Loop
which takes 10 mins (alot) to execute when i have over a million of lines in my code. Do you know how can i speed up the process for very large files ? the .txt files i read have this same format
Titlex
q1 0
q2 1
q3 1
q4 0
/
Titlexx
q1 0
q2 1
q3 1
q4 0
q5 1
without any limit in q1,q2,...,qx and the second word is 0 or 1 always
thanks beforehand