Solved

DataType Mismatch Criteria - VB.Net to MS Access

Posted on 2010-08-30
8
590 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
8 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

773 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