Solved

DataType Mismatch Criteria - VB.Net to MS Access

Posted on 2010-08-30
8
594 Views
Last Modified: 2012-08-13
VS 2005/ VB.Net

I am inserting to a Table.

All DataType and Query is perfectly correct, still i am getting these errors

System.Data.OleDb.OleDbException was caught
  ErrorCode=-2147217913
  Message="Data type mismatch in criteria expression."
  Source="Microsoft JET Database Engine"
 
0
Comment
Question by:chokka
[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
8 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 250 total points
ID: 33561646
Probably a good idea to post the SQL for the insert query :-)

mx
0
 

Author Comment

by:chokka
ID: 33561662


I am loading MS Access Database from VB.Net
Insert into tmpReport ([FirstName], [MiddleName],[LastName],[SSN],[Address],[City],[State],[Zip],[DOB],[IsMale],[HomePhone],[CellPhone],[WorkPhone],[ShippingAddress],[IsEmailShipment],[EmailAddress],[DCity],[DState],[DZip],[BestTimeToCall],[IsLeaveMsg],[IsPolicyHolder],[TypeofInsurance],[PolicyHolderName],[RelationshiptoPolicyHolder],[PolicyDOB],[PolicySSN],[Physician1],[Physician1PhnNumber],[Physician1FaxNumber],[Physician2],[Physician2PhnNumber],[Physician2FaxNumber],[Physician3],[Physician3PhnNumber],[Physician3FaxNumber],[CaseManager],[Organization],[CMPhoneNumber],[ReferredBy],[Relationship],[RelationPhoneNumber]) values ('" & txtFName.Text.Trim() & "','" & txtMIName.Text.Trim() & "','" & txtLName.Text.Trim() & "'," & iSSN & ",'" & strAddress & "','" & txtCity.Text.Trim() & "','" & strState & "'," & iZip & ",'" & txtDOB.Text.Trim() & "'," & isMale & "," & iHPn & "," & iCellPhone & "," & iWPhone & ",'" & strShipping & "'," & isEmailShipInfo & ",'" & txtEmail.Text.Trim() & "','" & txtDCity.Text.Trim() & "','" & strDState & "'," & txtDZipCode.Value.Trim() & ",'" & txtBestTimeToCall.Text.Trim() & "'," & isLeaveMsg & "," & isPolicyHolder & "," & iVariable & ",'" & txtPolicyHolderName.Text.Trim() & "','" & txtRelationshipPolicyHolder.Text.Trim() & "','" & txtPolicyHolderDOB.Text.Trim() & "'," & txtPolicySSN.Value.Trim() & ",'" & strPhy1 & "','" & txtP1Phn.Text.Trim() & "','" & txtP1Fax.Text.Trim() & "','" & strPhy2 & "','" & txtP2Phn.Text.Trim() & "','" & txtP2Fax.Text.Trim() & "','" & strPhy3 & "','" & txtP3Phn.Text.Trim() & "','" & txtP3Fax.Text.Trim() & "','" & strCM & "','" & txtOrganization.Text.Trim() & "'," & txtCPhoneNumber.Text & ",'" & txtReferredBy.Text.Trim() & "','" & txtRefRelationship.Text.Trim() & "','" & txtRefRelationshipPhoneNumber.Value.Trim() & "')

Open in new window

0
 
LVL 75
ID: 33561706
I don't see a WHERE clause for criteria - per the error.

mx
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

Author Comment

by:chokka
ID: 33561752
Its just normal INTO Statement
0
 
LVL 10

Expert Comment

by:Jini Jose
ID: 33561770
debug the code, and get the output of the insert query and then try to execute the query in access database directly. then you will get the exact error.
0
 
LVL 75
ID: 33561788
ok.  That error implies that you are tying to put ... for example ... a Text value in a Date/Time data type, Text value in a Numeric data type ... something to that effect.  Basically the wrong data type into a field with a different data type.

mx

0
 

Author Comment

by:chokka
ID: 33561814
i have kept all DateTime field as TEXT and passing as String
0
 
LVL 7

Assisted Solution

by:vbigham
vbigham earned 250 total points
ID: 33561961
Where you are passing Values like iSSN, iZip, isMale, iHPn, iCellPhone, iWPhone, isEmailShipInfo, isLeaveMsg, isPolicyHolder, iVariable

I am going to assume that variables starting with i are integers, and is are booleans.

You will want to make sure that your access database has the respective types (ex. iSSN will want SSN field to be integer, boolean for isMale etc.)  If you want to store only strings, you will want iSSN.ToString(), isMale.ToString()

Otherwise, it seems like you have the fields/values in the right order (couldn't hurt to double check).

Good luck.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

730 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