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

  • Home
  • SEARCH
  • 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 8881523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:21:53+00:00 2026-06-14T20:21:53+00:00

I have a very simple database in Access 2007 that I’m connecting to using

  • 0

I have a very simple database in Access 2007 that I’m connecting to using VB 2010. There are two tables, MenuItems and Orders, and Orders.orderDate is of type “Date”.

I’m running the following code in one of my VB forms (the connection string and everything else is fine):

  sql = "SELECT OrderDate, MenuItem FROM MenuItems, Orders WHERE Orders.itemID = MenuItem.ID AND Orders.orderDate BETWEEN '" + fromDate + "' AND '" + toDate + "'"
  Dim cmd As New OleDb.OleDbCommand(sql, con)
  Dim count As Integer = cmd.ExecuteNonQuery()

But I get an error that:

System.Data.OleDb.OleDbException (0x80040E10): value wan't given for one or more of the required parameters

Nothing seems to be missing. I’ve used the same code for another query, except the sql was different. But I think my sql is simple enough. Here’s the sql that was generated in one instance (I’ve double checked, all table and column names are correct):

SELECT OrderDate, MenuItem From MenuItems, Orders WHERE Orders.itemID = MenuItem.ID AND Orders.orderDate BETWEEN '11/21/2012' AND '11/24/2012'
  • 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-14T20:21:54+00:00Added an answer on June 14, 2026 at 8:21 pm

    You should use parametrized queries for at least two reasons.

    1. You don’t have to worry about date (and other) literals and locale problems.

    2. You don’t have to worry about SQL injection attacks, where someone enters malicious code in a text box that turns a SQL statement into a harmful one.

    Change your statement to

    sql = "SELECT Orders.OrderDate, MenuItems.MenuItem " & _
        "FROM MenuItems INNER JOIN Orders ON MenuItems.ID = Orders.itemID " & _
        "WHERE Orders.orderDate BETWEEN ? AND ?"
    

    Then execute the command like this

    Dim fromDate, toDate As DateTime
    
    fromDate = DateTime.Parse(fromDateTextBox.Text)
    toDate = DateTime.Parse(toDateTextBox.Text)
    
    Dim dataset As New DataSet()
    Using conn As New OleDbConnection(connectionString)
        Using adapter As New OleDbDataAdapter()
            Dim cmd As New OleDbCommand(sql, conn)
            cmd.Parameters.Add("?", fromDate)
            cmd.Parameters.Add("?", toDate)
            adapter.SelectCommand =  cmd
            adapter.Fill(dataset)
        End Using
    End Using
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple database table that joins two other tables in a
I have a very limited experience of database programming and my applications that access
I have a very small, simple sqlite database, and several python scripts to access
I currently have a very simple MySQL database (articlesDB) with 1 table (articles) and
I have a very simple Rails app with a very simple relational database: Category
I have a very simple scenario involving a database and a JMS in an
Very simple problem: I have a Public Sub (in a module) that I want
I'm a non-developer building a simple Access 2003 database for an NGO that works
I am writing a simple database with web access. I have previous experience with
I have created a simple application where I fetch questions from an Access database

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.