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



Dear ADO 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)

.



Relevant Pages

  • !VB.NET/Access: OleDbException (Data type mismatch in criteria expression)
    ... I'm getting very odd "Data type mismatch in criteria expression" errors that ... This fault only happens on one customer's database, ... OleDbException to find out precisely what column the type mismatch is ... We have an MSDN Subscription, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: SQL syntax for Autonumber, Currency and Date
    ... I took over this database ... Dim db As Database ... 'Note No Single quotes surrounding numeric field ... 'AutoNumber field, error 13 type mismatch ...
    (microsoft.public.access.formscoding)
  • Re: "Type Mis-match" error on an Option Group
    ... I've looked at your database, and found the problem to both items about ... Both problems result because you have the option group of buttons (the ones ... Because of this, the "type mismatch" error ... "Mike Webb" wrote in message ...
    (microsoft.public.access.macros)
  • Re: SQL syntax for Autonumber, Currency and Date
    ... Dim db As Database ... 'Note No Single quotes surrounding numeric field ... 'AutoNumber field, error 13 type mismatch ...
    (microsoft.public.access.formscoding)
  • Re: Trouble opening a form from a subform combo box
    ... > If the problem really is the data type mismatch, ... >> of changes to my database, ... >> I have a macro to open my form Documents. ...
    (microsoft.public.access.forms)