By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,344 Members | 1,114 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,344 IT Pros & Developers. It's quick & easy.

I am using Access2010 and VB2008 Express for my application. I get a Syntax error in

P: 2
Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Dim Cmd As New OleDbCommand
  3.         Dim SQL As String
  4.         Dim DbCmd As New OleDbCommand
  5.         Dim conn As New OleDbConnection()
  9.         conn.ConnectionString = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=C:\Documents and Settings\Owner\My Documents\Results2012.accdb"
  10.         conn.Open()
  11.         SQL = "INSERT INTO Game_Summary(Week,Opponent,Game1,Game2,Game3,OP Game1,OP Game2,OP Game3,Series,OP Series,Wins,OP Wins)" & _
  12.         "VALUES('?','?','?','?','?','?','?','?','?','?','?','?');"
  13.         Cmd = New OleDbCommand(SQL, conn)
  14.         Cmd.Parameters.AddWithValue("Week", ListBox2.Text)
  15.         Cmd.Parameters.AddWithValue("Opponent", TextBox89.Text)
  16.         Cmd.Parameters.AddWithValue("Game1", TextBox26.Text)
  17.         Cmd.Parameters.AddWithValue("Game2", TextBox27.Text)
  18.         Cmd.Parameters.AddWithValue("Game3", TextBox28.Text)
  19.         Cmd.Parameters.AddWithValue("OP Game1", TextBox55.Text)
  20.         Cmd.Parameters.AddWithValue("OP Game2", TextBox67.Text)
  21.         Cmd.Parameters.AddWithValue("OP Game3", TextBox68.Text)
  22.         Cmd.Parameters.AddWithValue("Series", TextBox29.Text)
  23.         Cmd.Parameters.AddWithValue("Op Series", TextBox83.Text)
  24.         Cmd.Parameters.AddWithValue("Wins", TextBox63.Text)
  25.         Cmd.Parameters.AddWithValue("Op Wins", TextBox71.Text)
  29.         DbCmd = New OleDbCommand(SQL, conn)
  30.         DbCmd.ExecuteNonQuery()
  31.         conn.Close()
Oct 10 '12 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 10K+
P: 12,382
Please use code tags when posting code.

I have no idea what your question is.

But I'll take a stab at the solution and it's because you use nonstandard characters in your field names (in this case, spaces). When you do that, you must demarcate it as a field using square brackets.
Expand|Select|Wrap|Line Numbers
  1. [OP Game1]
You should also not give your parameters the same name as your fields, that will just cause ambiguity.
Oct 10 '12 #2

P: 2
I understand completely
Oct 10 '12 #3

Post your reply

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