VB.Net "Syntax Error" in Execute statement.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ChildProgrammer
    New Member
    • Jun 2007
    • 9

    VB.Net "Syntax Error" in Execute statement.

    I am trying to upload data into an Access db from vb.net. The data was parsed out from text files. Everything seems to be working fine up till the .execute point. The debugger insists there is a syntax error in my statement, but when I check my insert into statement, I get what I expect. What am I doing wrong? Here is my code.:

    [code=vb]Dim str As String
    Dim s As ADODB.Connectio n = New ADODB.Connectio n
    Dim cmd As OleDbCommand

    s.ConnectionStr ing = "Provider=Micro soft.Jet.OLEDB. 4.0;" & "Data Source=" & "c:\x.mdb" & ";" & "Persist Security Info=False"


    str = "INSERT INTO IS " & _
    "(Fi,Da,St,En,I n,Ba,Wa,Bat,Ele ,Ver,VS,BeD,Ee) " & _
    " VALUES (" & strFi & "," & strDa & "," & strST & "," & strET & "," & strIn & "," & strBS & "," & strWa & "," & strBT & "," & strEer & "," & strVS & "," & strVSt & "," & strBD & "," & strEe & ")"


    s.Execute(str)

    s.Close()[/code]
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, ChildProgrammer .

    I award 3 points for creative use of [I] tags. Unfortunately, I have to deduct 3 points for using [I] tags when [CODE=vb] tags were called for.

    Better luck next time.

    Moving to the .NET forum....

    Comment

    • ChildProgrammer
      New Member
      • Jun 2007
      • 9

      #3
      Originally posted by pbmods
      Heya, ChildProgrammer .

      I award 3 points for creative use of [I] tags. Unfortunately, I have to deduct 3 points for using [I] tags when [CODE=vb] tags were called for.

      Better luck next time.

      Moving to the .NET forum....
      Leaving me with no point huh? Fair enough. lol

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Originally posted by ChildProgrammer
        I am trying to upload data into an Access db from vb.net. The data was parsed out from text files. Everything seems to be working fine up till the .execute point. The debugger insists there is a syntax error in my statement, but when I check my insert into statement, I get what I expect. What am I doing wrong? Here is my code.:

        [code=vb]Dim str As String
        Dim s As ADODB.Connectio n = New ADODB.Connectio n
        Dim cmd As OleDbCommand

        s.ConnectionStr ing = "Provider=Micro soft.Jet.OLEDB. 4.0;" & "Data Source=" & "c:\x.mdb" & ";" & "Persist Security Info=False"


        str = "INSERT INTO IS " & _
        "(Fi,Da,St,En,I n,Ba,Wa,Bat,Ele ,Ver,VS,BeD,Ee) " & _
        " VALUES (" & strFi & "," & strDa & "," & strST & "," & strET & "," & strIn & "," & strBS & "," & strWa & "," & strBT & "," & strEer & "," & strVS & "," & strVSt & "," & strBD & "," & strEe & ")"


        s.Execute(str)

        s.Close()[/code]
        Hi ChildProgrammer :)

        Check out this .NET article on how to use a database in your program. See if it helps you out.

        -Frinny

        Comment

        Working...