title: How to import contents of text file into mysql table in vb.net?
body: <p>I've searched different forums on this one, but still no luck.
  I have tried different codes, so far my query looks like this:</p>
  
  <pre><code>Dim query As String
  query = "LOAD DATA LOCAL INFILE 'C:\swipeimport\A1_20130513.txt' INTO TABLE tbl_entrance_swipe (@var1)" &amp; _
             "SET Loc=SUBSTRING(@var1,1,3)," &amp; _
             "date=SUBSTRING(@var1,4,8)," &amp; _
             "time=SUBSTRING(@var1,12,3)," &amp; _
             "temp=SUBSTRING(@var1,16,3)," &amp; _
             "id=SUBSTRING(@var1,19,10);"
      con.Open()
  
      Dim sql As MySqlCommand = New MySqlCommand(query, con)
  
      Dim i As Integer = sql.ExecuteNonQuery()
      If (i &gt; 0) Then
          MsgBox("Record is Successfully Inserted")
      Else
          MsgBox("Record is not Inserted")
      End If
      con.Close()
  </code></pre>
  
  <p>I want to import the contents of a text file into table, my table has this fields:</p>
  
  <pre><code>Loc, date, time, temp, id.
  </code></pre>
  
  <p>The content of the text file looks like this:</p>
  
  <pre><code>K0720130514045501018006D9566
  </code></pre>
  
  <p>where the breakdown is as follows:</p>
  
  <pre><code>K07        ----&gt; Loc
  20130514   ----&gt; date
  0455       ----&gt; time
  010        ----&gt; temp
  18006D9566 ----&gt; id
  </code></pre>
  
  <p>could you help, i cannot insert this in my table. What is the problem with my code?
  It just give a fatal error. Please point me in the right direction. Any help is very much appreciated. Thank you.</p>
  
  <p>EDIT:</p>
  
  <p>Here is my connection string:</p>
  
  <pre><code>Dim con As MySqlConnection = New MySqlConnection("Data Source=dev;Database=mydb;User ID=root;Password=mypass;")
  </code></pre>