Solved

DataType Mismatch Criteria - VB.Net to MS Access

Posted on 2010-08-30
8
596 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server views 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 Access…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

688 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