Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8710051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:31:25+00:00 2026-06-13T04:31:25+00:00

When I run the code below I keep getting the error message: Syntax error

  • 0

When I run the code below I keep getting the error message: Syntax error (missing operator) in query expression. What am I doing wrong?

con = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Database1.accdb"
connOledb.ConnectionString = con

connOledb.Open()
command = New OleDb.OleDbCommand("INSERT INTO Artikels VALUES('1'," + txtOmsch.Text + _
                   "','" + txtCat.Text + "','" + txtAPE.Text + _
                   "','" + txtMarge.Text + "','" + txtVPE.Text + _
                   "','" + txtEen.Text + "','" + txtLen.Text + _
                   "','" + txtBreed.Text + "','" + txtDiep.Text + _
                   txtOmsch.Text + "');")

command.Connection = connOledb
command.ExecuteNonQuery()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:31:26+00:00Added an answer on June 13, 2026 at 4:31 am

    you have missed a single quote for the second value. try this,

    command = New OleDb.OleDbCommand("INSERT INTO Artikels VALUES('1','" + txtOmsch.Text + _
                                   "','" + txtCat.Text + "','" + txtAPE.Text + _
                                   "','" + txtMarge.Text + "','" + txtVPE.Text + _
                                   "','" + txtEen.Text + "','" + txtLen.Text + _
                                   "','" + txtBreed.Text + "','" + txtDiep.Text + _
                                   txtOmsch.Text + "');")
    

    your code is vulnerable with sql injection, please use parameterized query since you are using ADO.NET, better try this code below,

    Dim con As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Database1.accdb"  
    Dim query As String = "INSERT INTO Artikels VALUES(@val1, @Omsch, @Cat, @Ape, @VPE, @Een, @len, @breed, @diep,@Omsch)")
    
    Using connOledb As New OleDbConnection(con)
        Using  command As New OleDbCommand()
            With command
                .Connection = con
                .CommandType = CommandType.Text
                .CommandText = query
                .Parameters.AddWithValue("@val1",1)
                .Parameters.AddWithValue("@Omsch",txtOmsch.Text)
                .Parameters.AddWithValue("@Cat",txtCat.Text)
                .Parameters.AddWithValue("@Ape",txtAPE.Text)
                .Parameters.AddWithValue("@VPE",txtVPE.Text)
                .Parameters.AddWithValue("@Een",txtEen.Text )
                .Parameters.AddWithValue("@len",txtLen.Text)
                .Parameters.AddWithValue("@breed",txtBreed.Text)
                .Parameters.AddWithValue("@diep",txtDiep.Text)
            End with
            Try
                connOledb.Open()
                command.ExecuteNonQuery()
            Catch(ex as OleDBException)
                Msgbox(ex.Message.Tostring())
            End Try
        End Using
    End Using
    

    or Add

    .Add("@Omsch", OleDbType.VarChar, 30).Value = txtOmsch.Text
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run the code below and I keep getting this error back:
I keep keep getting the above error when I run the code below. All
I keep getting this whenever I run the below code: Fatal error: Call to
When i run the below code I am getting error like ex = {The
I get this error when I run the code below. I have normally used
When I run below code, it's giving a message that: the application stopped unexcepctedlly
G'day folks I keep getting the error above whenever I run this and buggered
I keep getting a invalid identifier exception when I try to run the below
I keep getting a 'System.OutOfMemoryException' thrown at the code below. I can't figure out
Every time I run the code below it is supposed to come up with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.