output table not found while inserting data from vb to access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mevblearner
    New Member
    • Mar 2008
    • 4

    output table not found while inserting data from vb to access

    [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
    Last edited by Killer42; Mar 11 '08, 04:29 AM. Reason: Added CODE=vbnet tag, bolded error message
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Do you use Option Explicit and/or Option Strict? I see what look like a few mistyped variable names and the like, which might really stuff up the code. Whether they have anything to do with this particular problem, I don't know.

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      check the field name properly. There might be a space or something which is creating the error. Also ensure that you have connected to the proper database.

      Comment

      • mevblearner
        New Member
        • Mar 2008
        • 4

        #4
        Originally posted by debasisdas
        check the field name properly. There might be a space or something which is creating the error. Also ensure that you have connected to the proper database.
        Thanx for telling me that, there was a space when i checked the name properties

        Comment

        • mevblearner
          New Member
          • Mar 2008
          • 4

          #5
          Originally posted by Killer42
          Do you use Option Explicit and/or Option Strict? I see what look like a few mistyped variable names and the like, which might really stuff up the code. Whether they have anything to do with this particular problem, I don't know.
          i got the error fixed it was with a space in the name of field i didnt realise it till i saw the properties of field name thanks for your help

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Glad we could help. :)

            Even if it wasn't related to this problem, I do recommend using Option Explicit at all times. Possibly also Option Strict, but I don't have any experience with that (because I use an old version).

            Comment

            • mevblearner
              New Member
              • Mar 2008
              • 4

              #7
              Originally posted by Killer42
              Glad we could help. :)

              Even if it wasn't related to this problem, I do recommend using Option Explicit at all times. Possibly also Option Strict, but I don't have any experience with that (because I use an old version).
              How do i output result of as ql query to a text file in vb

              Comment

              Working...