I am trying to load bulk records of text files in my database using VB.NET and I run into a fatal error.
HERE'S MY CODE:
Public Sub LoadStudent(ByVal filepath As String)
Dim sql As String
sql = "load data infile local '" & filepath & "' into table student_academic_table fields terminated by '\t' lines terminated by '\r\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8, @col9, @col10, @col11, @col12, @col13) set StudentIDNumber = @col1, LastName = @col2, FirstName = @col3, MiddleName = @col4, Course = @col5, _Year = @col6, Gender = @col7, OfferCode = @col8, SubjectName = @col9, SubjectDescription = @col10, MidtermGrade = @col11, FinalGrade = @col12, Units = @col13, TermCode = 0;"
SC.LoadData(sql)
End Sub
Here's the code for SC.LoadData(sql):
Public Function LoadData(ByVal sql As String) As Long
If sql.Trim.ToLower.StartsWith("load") Then
Try
Connect()
cmd.CommandText = sql
cmd.Connection = con
Return cmd.ExecuteNonQuery()
Disconnect()
Catch ex As MySqlException
Console.Write(ex.Message)
MessageBox.Show(ex.Message)
End Try
End If
Return 0
End Function
I made it as a sub so that I can use it to other functions, but it doesn't carry on the desired function that I want it to do, instead it throws a fatal error exception in the database. I tried executing it directly in my MySql Query Browser and it executed. But in my VB.NET application it fires a fatal error, I've already looked up in google and other forums for related articles or topics but I couldn't find any answer. My guess its version compatibility and I have no idea how to fix these kind of problems. PLEASE HELP.