Hi,
I had this code working to import one column in a table as a starter point, but now that i'm trying to import all the columns in the table, i'm running into problems.
When I run the app, I get this Microsoft . NET Framework error:
Syntax error in INSERT INTO statement
I've tried just about every combination I can think of for the sql statement and still the same error message.
Can anyone help me identify my error?
I had this code working to import one column in a table as a starter point, but now that i'm trying to import all the columns in the table, i'm running into problems.
When I run the app, I get this Microsoft . NET Framework error:
Syntax error in INSERT INTO statement
I've tried just about every combination I can think of for the sql statement and still the same error message.
Can anyone help me identify my error?
Code:
Imports System.IO
Imports System.Data.OleDb
Public Class Update2
Sub LoadData()
Dim objStreamReader As StreamReader = File.OpenText("/CMgmt/import.csv")
While objStreamReader.Peek() <> -1
Dim Str1() As String = Split(objStreamReader.ReadLine(), ",")
AddRecord(Str1(0), Str1(1), Str1(2), Str1(3), Str1(4), Str1(5), Str1(6))
End While
objStreamReader.Close()
End Sub
Sub AddRecord(ByVal first As String, ByVal last As String, ByVal address As String, ByVal postal As String, ByVal city As String, ByVal prov As String, ByVal tel As String)
Dim objConnection As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=/CMgmt/CMgmt.mdb")
objConnection.Open()
Dim SQL As String = "INSERT INTO [Import_T](first,last,address,postal,city,prov,tel) VALUES ('" & first & "','" & last & "','" & address & "','" & postal & "','" & city & "','" & prov & "','" & tel & "')"
Dim objCommand As OleDbCommand
objCommand = New OleDbCommand(SQL, objConnection)
objCommand.ExecuteNonQuery()
objConnection.Close()
End Sub
Private Sub Update2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.LoadData()
Application.Exit()
End Sub
End Class
Comment