Hi
I've got a problem in Importing Text delimited File to access Db , I always get an error "No value given for one or more required parameters'
while execution [Select Into] Statement
Dim svdialog As New SaveFileDialog
svdialog.Filter = "Access Database Files (*.mdb)/*.mdb"
If svdialog.ShowDialog = Windows.Forms.DialogResult.Cancel Then Exit Function
svdialog.Title = "Save Track DB"
CreateAccessDatabase(svdialog.FileName)
Dim ds As New DataSet
Dim da As New OleDbDataAdapter
'Define the connectors
Dim oConn As OleDbConnection
Dim oComm As OleDbCommand
Dim oConnect, oQuery As String
'Define connection string
oConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & svdialog.FileName
'Define the query string the creates the table
oQuery = "CREATE TABLE TABLE1 (ID Autoincrement, " & _
"[Date] DATETIME," & _
"[Time] DATETIME," & _
"[Valid_position] TEXT(100) NOT NULL," & _
"[Lat] NUMBER NOT NULL," & _
"[Long] NUMBER NOT NULL," & _
"[Speed] NUMBER NOT NULL," & _
"CONSTRAINT ID PRIMARY KEY(ID) )"
'' Instantiate the connectors
oConn = New OleDbConnection(oConnect)
oComm = New OleDbCommand(oQuery, oConn)
'Open the connection
oConn.Open()
' 'Perform the Non-Query
oComm.ExecuteNonQuery()
' 'Close the connection
oConn.Close()
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & svdialog.FileName) '& "Extended Properties='text;FMT=TabDelimited;HDR=YES'")
Dim myFile() As String = System.IO.File.ReadAllText("D:\Tracks\Text.txt").Split(","c)
'For Each line As String In myFile
Dim cmd As New OleDbCommand("Insert INTO TABLE1 ([Date],[Time],[Valid_position],[Lat],[Long],[Speed])" & _
" SELECT F1 as [Date],F2 as [Time],F3 as [Valid_position],F4 as [Lat],F5 as [Long],F6 as [Speed]" & _
" FROM [Text;Database=c:\;FMT=Delimited].[Text.txt];", conn)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()here's the text file is attatched
I've got a problem in Importing Text delimited File to access Db , I always get an error "No value given for one or more required parameters'
while execution [Select Into] Statement
Dim svdialog As New SaveFileDialog
svdialog.Filter = "Access Database Files (*.mdb)/*.mdb"
If svdialog.ShowDialog = Windows.Forms.DialogResult.Cancel Then Exit Function
svdialog.Title = "Save Track DB"
CreateAccessDatabase(svdialog.FileName)
Dim ds As New DataSet
Dim da As New OleDbDataAdapter
'Define the connectors
Dim oConn As OleDbConnection
Dim oComm As OleDbCommand
Dim oConnect, oQuery As String
'Define connection string
oConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & svdialog.FileName
'Define the query string the creates the table
oQuery = "CREATE TABLE TABLE1 (ID Autoincrement, " & _
"[Date] DATETIME," & _
"[Time] DATETIME," & _
"[Valid_position] TEXT(100) NOT NULL," & _
"[Lat] NUMBER NOT NULL," & _
"[Long] NUMBER NOT NULL," & _
"[Speed] NUMBER NOT NULL," & _
"CONSTRAINT ID PRIMARY KEY(ID) )"
'' Instantiate the connectors
oConn = New OleDbConnection(oConnect)
oComm = New OleDbCommand(oQuery, oConn)
'Open the connection
oConn.Open()
' 'Perform the Non-Query
oComm.ExecuteNonQuery()
' 'Close the connection
oConn.Close()
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & svdialog.FileName) '& "Extended Properties='text;FMT=TabDelimited;HDR=YES'")
Dim myFile() As String = System.IO.File.ReadAllText("D:\Tracks\Text.txt").Split(","c)
'For Each line As String In myFile
Dim cmd As New OleDbCommand("Insert INTO TABLE1 ([Date],[Time],[Valid_position],[Lat],[Long],[Speed])" & _
" SELECT F1 as [Date],F2 as [Time],F3 as [Valid_position],F4 as [Lat],F5 as [Long],F6 as [Speed]" & _
" FROM [Text;Database=c:\;FMT=Delimited].[Text.txt];", conn)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()