473,748 Members | 2,672 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

data type mismatch in criteria expression

2 New Member
I am firing an insert query like this in C# to MS ACCESS 07 Database
Expand|Select|Wrap|Line Numbers
  1. var expiry = dateTimePicker1.Text;
  2.  string instr = "insert into MST_QUOTATION values(";
  3.                  instr += txtID.Text;
  4.                  instr += "," + txtcustid.Text;
  5.                  instr += ",'" + txtCustname.Text; 
  6.                  instr += "','" + txtAdd1.Text;
  7.                  instr += "','" + txtZip.Text;
  8.                  instr += "'," + txtContact.Text;
  9.                  instr += ",'" + txtEmail.Text;
  10.                  instr += "','" + expiry;
  11.                  instr += "','" + expiry;
  12.                  instr += "');";
  13.  
  14.                  cmd = new OleDbCommand(instr, cn);
  15.               cmd.ExecuteNonQuery();
// Now i m getting error like this
data type mismatch in criteria expression
please help me
Feb 12 '13 #1
2 4215
Mikkeee
94 New Member
Looks like you need to check your query string against the data types in your table. Print your instr variable to the immediate window and post it along with your MST_QUOTATION table schema.
Feb 12 '13 #2
Rabbit
12,516 Recognized Expert Moderator MVP
If expiry is a date, then Access uses # symbols to demarcate dates.

Also, you should be aware that your code is succeptible to SQL injection attacks. You should escape your dynamic values.
Feb 12 '13 #3

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

Similar topics

1
6544
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 was once a type Number, but I had to change it to a type Text due to I needed to have two zeros at the beginning of the Asset Number (EX: 001234.) The rease I am writing is that now when I run from My Query Menu a
4
3144
by: N J | last post by:
Hi, CurrentDb.Execute "Update tblDelayedOrders Set DELAYED = True Where ID = " & Me.txtOrderNumber & ";", dbfailonerror Me.StatusListBox.AddItem "ORDER # " & Me.txtOrderNumber & " MARKED AS DELAYED " & "" & "", 0 When I change Where ID to Where TRACKING (another text field) I get the error Data Type Mismatch in expression critera, or something like that
3
6509
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 criteria, the Mid function returns the values when I run the query. So if one of the values is a "t" (no quotes), can I not ask to isolate that record by putting "t" as a criteria? Nope - error, error. If I put it within the expression itself...
1
3281
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. Source Error: Line 233: Line 234: rs =
2
2590
by: technocraze | last post by:
Hi guys, Implementations application & programming environ MS Acess + Visual Basic Table fields Serialno (pk) - Auto number StudentId - text Course - text intake - number
10
6235
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 cross-tab query I am using a simple query with no grouping where I am filtering some data out in the criteria line. I have been out of access for a couple years but I remember in the past I had a solution for this but I can't remember. Any help...
2
9000
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. -------------------------------------------------------------------------------- Data type mismatch in criteria expression.
19
21569
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 date is more than 10 months out. The query runs fine, but I when I put the criteria of >10 I get 'Data Type mismatch' error. The code below is the original query. I have since put all the datediff bit in code, with all variables declared as date,...
1
2714
by: DC | last post by:
Any idea why this code would cause a error? The SQL that gets executed seems to be (using record 1132 as an example) DELETE FROM user_table WHERE ID = '1132'; And the value of ViewState("ID") =1132 ID is an Access database autonumber field. Is Viewstate data passed as an odd type or something?
2
3953
by: tmoon3 | last post by:
Hello, This must be a simple mistake, but for some reason I cannot seem to get around it. I am simply trying to create a report of all employees that have a date filled in in a training column in an access DB. I give the users a drop down list to choose employee type, division, and term status and based on their choices I create the selection criteria for the report. This code works without the ForkTruckClass > '#1-01-1900#' (the below...
0
8995
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9561
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9381
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9332
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.