Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Date mismatch when using number type in Access

Posted on 2004-04-17
3
Medium Priority
?
291 Views
Last Modified: 2010-04-24
Hi,

I used to use String type for all my variable types in my Access DB even for variables with number types like IDs.

Due to some constraints i have to use Number types for my IDs now.

Here is an example of my SQL which has a data mismatch error.

Dim item As Integer
item = Request.QueryString("topicID")

Cmd = New OleDb.OleDbCommand("Select topicID ForumPosts where topicID ='" + item + "'", Conn)

I have also tried enclosing item in  only double quotes "+item+" or single quotes '+item+', and still the same error occurs.

It produces a data mismatch error. So what is the problem lying here?
0
Comment
Question by:FYPJ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Expert Comment

by:burakiewicz
ID: 10849767
for integers in access you don't use any quotes ex
Cmd = New OleDb.OleDbCommand("Select topicID ForumPosts where topicID =" + item + ", Conn)
0
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 200 total points
ID: 10849846
minor correction to the answer above:

Should read:

Cmd = New OleDb.OleDbCommand("Select topicID ForumPosts where topicID =" & item , Conn)

there is no need for the closing "", and the concatenation operator (to append a value to a string, is the & operator, not the + operator.

Since Item is declared as an Integer, you must use it that way.  in the SQL that you originally had, you are trying to compare a STRING (the '<itemvalu>' is a string), with a Number (the field in the table is of type number, hence the type mismatch.

Also, the + operator is trying to ADD (like 1+2) numbers, and you have a string on one side and a number on the other, and that ALSO gives a type Mismatch error.

AW
0
 

Author Comment

by:FYPJ
ID: 10852078
OK thanks for both the answers.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question