468,720 Members | 1,579 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,720 developers. It's quick & easy.

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.:

Expand|Select|Wrap|Line Numbers
  1. Dim str As String
  2. Dim s As ADODB.Connection = New ADODB.Connection
  3. Dim cmd As OleDbCommand
  4.  
  5. s.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & "c:\x.mdb" & ";" & "Persist Security Info=False"
  6.  
  7.  
  8. str = "INSERT INTO IS " & _
  9.             "(Fi,Da,St,En,In,Ba,Wa,Bat,Ele,Ver,VS,BeD,Ee) " & _
  10.             " VALUES (" & strFi & "," & strDa & "," & strST & "," & strET & "," & strIn & "," & strBS & "," & strWa & "," & strBT & "," & strEer & "," & strVS & "," & strVSt & "," & strBD & "," & strEe & ")"
  11.  
  12.  
  13. s.Execute(str)
  14.  
  15. s.Close()
Jun 25 '07 #1
3 2300
pbmods
5,821 Expert 4TB
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....
Jun 25 '07 #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....
Leaving me with no point huh? Fair enough. lol
Jun 25 '07 #3
Frinavale
9,735 Expert Mod 8TB
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.:

Expand|Select|Wrap|Line Numbers
  1. Dim str As String
  2. Dim s As ADODB.Connection = New ADODB.Connection
  3. Dim cmd As OleDbCommand
  4.  
  5. s.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & "c:\x.mdb" & ";" & "Persist Security Info=False"
  6.  
  7.  
  8. str = "INSERT INTO IS " & _
  9.             "(Fi,Da,St,En,In,Ba,Wa,Bat,Ele,Ver,VS,BeD,Ee) " & _
  10.             " VALUES (" & strFi & "," & strDa & "," & strST & "," & strET & "," & strIn & "," & strBS & "," & strWa & "," & strBT & "," & strEer & "," & strVS & "," & strVSt & "," & strBD & "," & strEe & ")"
  11.  
  12.  
  13. s.Execute(str)
  14.  
  15. s.Close()
Hi ChildProgrammer :)

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

-Frinny
Jun 25 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Rachel McConnell | last post: by
6 posts views Thread by ewpatton | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Oskars | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.