Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datatype Mismatch in Update Command and Concurrency Checks

Status
Not open for further replies.

MajP

Technical User
Aug 27, 2005
9,382
0
0
US
I am using the Access Northwind database to teach myself ADO.net and building a VB database. I am using strong typed dataset. I have an orders tableadapter and the wizard generates the following updated command text.

Code:
UPDATE Orders SET
    [Employee ID] = ?, 
    [Customer ID] = ?, 
    [Order Date] = ?, 
    [Shipped Date] = ?, 
    [Shipper ID] = ?, 
    [Ship Name] = ?, 
    [Ship Address] = ?, 
    [Ship City] = ?, 
    [Ship State/Province] = ?,
    [Ship ZIP/Postal Code] = ?, 
    [Ship Country/Region] = ?, 
    [Shipping Fee] = ?, 
    Taxes = ?, 
    [Payment Type] = ?, 
    [Paid Date] = ?, 
    Notes = ?, 
    [Tax Rate] = ?, 
    [Tax Status] = ?, 
    [Status ID] = ?
WHERE  ([Order ID] = ?) 
       AND (? = 1 AND [Employee ID] IS NULL OR [Employee ID] = ?) 
       AND (? = 1 AND [Customer ID] IS NULL OR [Customer ID] = ?) 
       AND (? = 1 AND [Order Date] IS NULL OR  [Order Date] = ?) 
       AND (? = 1 AND [Shipped Date] IS NULL OR [Shipped Date] = ?) 
       AND (? = 1 AND [Shipper ID] IS NULL OR [Shipper ID] = ?) 
       AND (? = 1 AND [Ship Name] IS NULL OR [Ship Name] = ?) 
       AND (? = 1 AND [Ship City] IS NULL OR  [Ship City] = ?) 
       AND (? = 1 AND [Ship State/Province] IS NULL OR  [Ship State/Province] = ?) 
       AND (? = 1 AND [Ship ZIP/Postal Code] IS NULL OR [Ship ZIP/Postal Code] = ?) 
       AND (? = 1 AND [Ship Country/Region] IS NULL OR [Ship Country/Region] = ?) 
       AND (? = 1 AND [Shipping Fee] IS NULL OR [Shipping Fee] = ?) 
       AND (? = 1 AND Taxes IS NULL OR Taxes = ?) 
       AND (? = 1 AND [Payment Type] IS NULL OR [Payment Type] = ?) 
       AND (? = 1 AND [Paid Date] IS NULL OR [Paid Date] = ?) 
       AND (? = 1 AND [Tax Rate] IS NULL OR [Tax Rate] = ?) 
       AND (? = 1 AND [Tax Status] IS NULL OR [Tax Status] = ?) 
       AND (? = 1 AND [Status ID] IS NULL OR [Status ID] = ?)

When I try to run the update query I get a datatype mistmatch error. If however I remove the concurrency checks in the where clause, and only check the primary key

Code:
WHERE  ([Order ID] = ?)

The code runs fine. Any ideas what could cause this? Thanks.
 
Try putting parentheses around your OR statements --> AND (? = 1 AND ([Employee ID] IS NULL OR [Employee ID] = ?))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top