1 Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5. Click 2 Try 3 Dim file_name As String = "E:\EXPORTDATA\customerInformation.txt" 4 Dim txtline, q, data(4) As String 5 6 7 If System.IO.File.Exists(file_name) = True Then 8 Dim objreader As New System.IO.StreamReader(file_name) 9 Do While objreader.Peek <> -1 10 ' Storing line to string variable 11 txtline = objreader.ReadLine() & vbNewLine 12 'breaking the line & stroing to array variable 13 data = txtline.Split(",") 14 q = "insert into customer_info values(@CUSTOMER_NAME,@CUSTOMER_ID,@CUSTOMER_ADD,@CITY)" 15 con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:E\connectivity\MYDB.accdb;" 16 17 con.Open() 18 19 cmd = New OleDbCommand(q, con) 20 cmd.Connection = con 21 22 With cmd.Parameters 23 .Add("@CUSTOMER_NAME", OleDbType.VarChar).Value = data(0) 24 .Add("@CUSTOMER_ID", OleDbType.VarChar).Value = data(1) 25 .Add("@CUSTOMER_ADD", OleDbType.VarChar).Value = data(2) 26 .Add("@CITY", OleDbType.VarChar).Value = data(3) 27 28 End With 29 cmd.ExecuteNonQuery() 30 con.Close() 31 Loop 32 End If 33 34 MessageBox.Show("Data Saved") 35 36 Catch ex As Exception 37 MsgBox(ex.Message.ToString) 38 End Try 39 40 End Sub
con
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)