Solved

Date mismatch when using number type in Access

Posted on 2004-04-17
3
284 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 50 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 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