M
Mike Wilson
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)
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)