[CODE=vbnet]
Imports System.IO
Imports System.Data
Imports System.Data.Ole Db
Public Class Form1
Public Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Dim SourceFile1 As StreamReader
Dim orderline1 As String
Dim splitarr(0 To 38) As String
Dim splitarr1(0 To 32) As String
Dim store1 As String
'Dim customerpo As String
Dim searchthis As String = "order_line "
Dim searchthis1 As String = "order_head "
Dim Str As String
Dim orderhead As String
Dim destFile As New StreamWriter("C :\o1.txt")
SourceFile1 = IO.File.OpenTex t("C:\test.txt" )
'database variables
Dim strSQL1 As String
Dim strSQL2 As String
Dim MDBConn As New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data Source =C:\db3.mdb")
Dim cmd As New OleDbCommand
MDBConn.Open()
cmd.Connection = MDBConn
MDBConn.Close()
' cmd.ExecuteNonQ uery()
'cmd.Connection = MDBConn
'Dim objconn As New OleDb.OleDbConn ection("CONNECT IONSTRING")
'Dim objCmd As OleDb.OleDbComm and
While SourceFile1.Pee k <> -1
Str = SourceFile1.Rea dLine
Dim CharThis2 As Integer = Str.IndexOf(sea rchthis)
If CharThis2 = 0 Then
Dim customerpo1 As String
orderline1 = Str
splitarr = Split(Str, ",", -1, CompareMethod.T ext)
store1 = splitarr(5)
customerpo1 = splitarr(15)
Try
cmd.CommandText = "INSERT INTO order11(orderli ne,store,cudtom erpo) VALUES('orderli ne1','store1',' customerpo1')"
MDBConn.Open()
'cmd.Connection = cmd
cmd.Connection = MDBConn
cmd.ExecuteNonQ uery()
MDBConn.Close()
Catch ex As OleDbException
MessageBox.Show (ex.Message)
End Try
End If
Dim CharThis3 As Integer = Str.IndexOf(sea rchthis1)
If CharThis3 = 0 Then
Dim customerpo As String
orderhead = Str
splitarr1 = Split(Str, ",", -1, CompareMethod.T ext)
customerpo = splitarr(13)
End If
End While
End Sub
End Class
[/CODE]
I get this error insert into statement contains the follwing field name orderline make sure you have typed the name correctly and try the operation again
Chked the field names but they same to be right i dont know what the issue here is please help
Imports System.IO
Imports System.Data
Imports System.Data.Ole Db
Public Class Form1
Public Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Dim SourceFile1 As StreamReader
Dim orderline1 As String
Dim splitarr(0 To 38) As String
Dim splitarr1(0 To 32) As String
Dim store1 As String
'Dim customerpo As String
Dim searchthis As String = "order_line "
Dim searchthis1 As String = "order_head "
Dim Str As String
Dim orderhead As String
Dim destFile As New StreamWriter("C :\o1.txt")
SourceFile1 = IO.File.OpenTex t("C:\test.txt" )
'database variables
Dim strSQL1 As String
Dim strSQL2 As String
Dim MDBConn As New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data Source =C:\db3.mdb")
Dim cmd As New OleDbCommand
MDBConn.Open()
cmd.Connection = MDBConn
MDBConn.Close()
' cmd.ExecuteNonQ uery()
'cmd.Connection = MDBConn
'Dim objconn As New OleDb.OleDbConn ection("CONNECT IONSTRING")
'Dim objCmd As OleDb.OleDbComm and
While SourceFile1.Pee k <> -1
Str = SourceFile1.Rea dLine
Dim CharThis2 As Integer = Str.IndexOf(sea rchthis)
If CharThis2 = 0 Then
Dim customerpo1 As String
orderline1 = Str
splitarr = Split(Str, ",", -1, CompareMethod.T ext)
store1 = splitarr(5)
customerpo1 = splitarr(15)
Try
cmd.CommandText = "INSERT INTO order11(orderli ne,store,cudtom erpo) VALUES('orderli ne1','store1',' customerpo1')"
MDBConn.Open()
'cmd.Connection = cmd
cmd.Connection = MDBConn
cmd.ExecuteNonQ uery()
MDBConn.Close()
Catch ex As OleDbException
MessageBox.Show (ex.Message)
End Try
End If
Dim CharThis3 As Integer = Str.IndexOf(sea rchthis1)
If CharThis3 = 0 Then
Dim customerpo As String
orderhead = Str
splitarr1 = Split(Str, ",", -1, CompareMethod.T ext)
customerpo = splitarr(13)
End If
End While
End Sub
End Class
[/CODE]
I get this error insert into statement contains the follwing field name orderline make sure you have typed the name correctly and try the operation again
Chked the field names but they same to be right i dont know what the issue here is please help
Comment