DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Mon, 16 Jul 2007 20:35:46 +0100,    posted on: microsoft.public.dotnet.framework.adonet        back       

Thread Index
  1    Mike Wilson


!VB.NET/Access: OleDbException (Data type mismatch in criteria expression)   
Dear ADO.NET experts!

I hope someone can help me, as I've been tearing my hair out with this one
all day!

I'm getting very odd "Data type mismatch in criteria expression" errors that
I can absolutely not nail down or debug at all.

SCREENSHOT:
http://img384.imageshack.us/img384/6564/oledbexceptionwb5.jpg

Using: VB.NET (2005/.NET 2.0 & MS Access (2000) MDB)

Process: This is a Wizard to make a monthly tax return. The user selects a
date from a pre-filled drop-down combo box and clicks "Next" to go to the
next page of the Wizard which loads payments (grouped by supplier) from the
Payments table into a DataGridView. The tableadapter fill method is called,
passing the From and To dates which are used to determine which payments are
shown in the DataGridView on the next page.

---

SQL (taken from the command property of the dataset designer):
SELECT Subcontractor_ID, SUM(Gross) AS Gross, SUM(DirectCostOfMaterials0dp)
AS DirectCostOfMaterials0dp, SUM(TotalAmountDeducted) AS
TotalAmountDeducted, SUM(Net) AS Net
FROM Payment
WHERE (PaymentDate >= ?) AND (PaymentDate < ?) AND (Company_ID = ?) AND
(MonthlyReturn_ID IS NULL OR MonthlyReturn_ID = '')
GROUP BY Subcontractor_ID

CODE:
' A tax month is from the 6th to the 5th of the following month
_FromIncDate = DateAdd(DateInterval.Day, 1, DateAdd(DateInterval.Month, -1,
CDate(cboMonthlyReturnPeriod.Text)))

_ToDate = DateAdd(DateInterval.Day, 1, CDate(cboMonthlyReturnPeriod.Text))

' Crashes on this line
taPayments.FillForNewMonthlyReturn(DsInvoice1.Payment, _FromIncDate,
_ToDate, My.Settings.CurrentCompany_ID)

---

I have checked, double-checked and re-checked the data
The table columns are defined as "DateTime" in Access, "DateTime" in the
DataSet designer, and the values passed as parameters to the .Fill function
are .NET Dates.
This fault only happens on one customer's database, although this database
appears to be no different to any of the other databases.
I had thought perhaps this was to do with regional settings, but cannot find
any evidence for this.

What can I do to prevent this from occurring, and how can I debug the
OleDbException to find out precisely what column the type mismatch is
referring to?

Warm Regards,

Mike Wilson

P.S. How does one go about subscribing to the Microsoft
privatenews.microsoft.com newsgroups? We have an MSDN Subscription, but the
links from the MSDN Subscriber Downloads page take you round in circles...

(also x-posted to: microsoft.public.dotnet.languages.vb.data - but forgot to
add this group)
Date:Mon, 16 Jul 2007 20:35:46 +0100   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us