473,403 Members | 2,323 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Data type mismatch in criteria expression.

Hi,

I've been trying to execute below query in C#.(DataBase :Access)

strTemp = "SELECT Students.Studentid, Persons.FirstName FROM (Persons INNER JOIN Students ON Persons.PersonId = Students.PersonId) " +
"WHERE Students.Studentid not in ( select UnableToEnterSchools.Studentid from UnableToEnterSchools where UnableToEnterSchools.SchoolId = " + SchoolId.ToString() + ")";

i.e...

SELECT Students.Studentid, Persons.FirstName FROM (Persons INNER JOIN Students ON Persons.PersonId = Students.PersonId) WHERE Students.Studentid not in ( select UnableToEnterSchools.Studentid from UnableToEnterSchools where UnableToEnterSchools.SchoolId = 1)

I'm getting below ERROR message,

Data type mismatch in criteria expression.

Please help me out in passing this obstacle.

Thanks in advance.

Regards,
Bob
Aug 2 '08 #1
3 1040
r035198x
13,262 8TB
.. where UnableToEnterSchools.SchoolId = " + SchoolId.ToString() + ")";

..
Your problem is probably in the quote above.
If the datatype of UnableToEnterSchools.SchoolId is some numeric value then you shouldn't be calling ToString() on SchoolId.ToString(). That would mean you are comparing a numeric column with a character column.
Aug 4 '08 #2
Curtis Rutland
3,256 Expert 2GB
I don't think that's the problem, r0. Since that is just the string building part, that's ok.

I think that you should post the actual string. Like, do a MessageBox or Console.WriteLine of the string that you build and show exactly what you are passing on to the database.
Aug 4 '08 #3
r035198x
13,262 8TB
I don't think that's the problem, r0. Since that is just the string building part, that's ok.

I think that you should post the actual string. Like, do a MessageBox or Console.WriteLine of the string that you build and show exactly what you are passing on to the database.
I see what you mean now. Perhaps the column definitions for the OP's tables should also be posted to provide more information.
Aug 4 '08 #4

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

Similar topics

1
by: ArcadeJr | last post by:
Good morning all! I have been getting a Run-time Error message #3464 - Data Type mismatch in criteria expression. While trying to run a query. I have a database where the field Asset_Number...
3
by: martlaco1 | last post by:
Trying to fix a query that (I thought) had worked once upon a time, and I keep getting a Data Type Mismatch error whenever I enter any criteria for an expression using a Mid function. Without the...
1
by: amitbadgi | last post by:
I am getting the following error while converting an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Data type mismatch in criteria expression. ...
2
by: igor.barbaric | last post by:
Hello! I have created a very simple query like this: SELECT Tasks.Name, DurationHrs(,) AS Duration FROM Tasks INNER JOIN Log ON Tasks.TaskID=Log.TaskID; The above query works fine....
10
by: aaronrm | last post by:
I have a real simple cross-tab query that I am trying to sum on as the action but I am getting the "data type mismatch criteria expression" error. About three queries up the food chain from this...
2
by: psychomad | last post by:
Please, can someone help me out to solve this error, i've been searching throughout my codes and yet i didnt succeed in finding the error!!!! The Error is: Server Error in '/' Application....
5
by: blackburnj55 | last post by:
Hi, I am constructing a website for a bike shop. I am using dreamweaver and an access database to create it. I have made a query where two criteria are entered to get results. These are :...
19
by: Lysander | last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the...
1
by: Bobby Edward | last post by:
Using Access db with VS2008 (ASP.NET/VB.NET).... On the INSERT command I get this error: System.Data.OleDb.OleDbException: Data type mismatch in criteria expression. I haven't found a...
9
by: nixonmg | last post by:
When the Command Button "Notify" is clicked, I am wanting to send out an email to the user with appropriate information in the email (works great), check the "Notified" check box (does not work), and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.