Solved

Error creating command

Posted on 2014-09-25
2
126 Views
Last Modified: 2014-09-26
Getting an ADO error when trying to create a command.  "Conversion failed when converting date and/or time from character string.

I don't normally use commands so I could be doing something wrong.

select
dbo.InvMaster.ConvFactOthUom,
dbo.InvMaster.StockCode,
dbo.SorDetail.SalesOrder,
dbo.SorDetail.MStockCode,
dbo.SorDetail.MStockDes,
dbo.SorDetail.MWarehouse,
dbo.SorDetail.MOrderQty,
dbo.SorDetail.MOrderUom,
dbo.SorDetail.MPrice,
dbo.SorDetail.MDiscValue,
dbo.SorDetail.MStockUnitMass,
dbo.SorDetail.MConvFactAlloc,
dbo.SorMaster.SalesOrder,
dbo.SorMaster.OrderStatus,
dbo.SorMaster.OrderDate

FROM dbo.InvMaster INNER JOIN
dbo.SorDetail ON dbo.InvMaster.StockCode = dbo.SorDetail.MStockCode INNER JOIN
dbo.SorMaster ON dbo.SorDetail.SalesOrder = dbo.SorMaster.SalesOrder

union


select
CompanyY.dbo.InvMaster.ConvFactOthUom,
CompanyY.dbo.InvMaster.StockCode,
CompanyY.dbo.SorDetail.SalesOrder,
CompanyY.dbo.SorDetail.MStockCode,
CompanyY.dbo.SorDetail.MStockDes,
CompanyY.dbo.SorDetail.MWarehouse,
CompanyY.dbo.SorDetail.MOrderQty,
CompanyY.dbo.SorDetail.MOrderUom,
CompanyY.dbo.SorDetail.MPrice,
CompanyY.dbo.SorDetail.MDiscValue,
CompanyY.dbo.SorDetail.MStockUnitMass,
CompanyY.dbo.SorDetail.MConvFactAlloc,
CompanyY.dbo.SorMaster.SalesOrder,
CompanyY.dbo.SorMaster.OrderDate,
CompanyY.dbo.SorMaster.OrderStatus

FROM CompanyY.dbo.InvMaster INNER JOIN
CompanyY.dbo.SorDetail ON CompanyY.dbo.InvMaster.StockCode = CompanyY.dbo.SorDetail.MStockCode INNER JOIN
CompanyY.dbo.SorMaster ON CompanyY.dbo.SorDetail.SalesOrder = CompanyY.dbo.SorMaster.SalesOrder
0
Comment
Question by:TomBalla
[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
2 Comments
 
LVL 35

Accepted Solution

by:
James0628 earned 500 total points
ID: 40345697
You have the last 2 columns in a different order in the 2 queries -- OrderStatus and then OrderDate in the first one, and the other way around in the second.

 The first query makes the last column a date/datetime, and then the second query tries to put OrderStatus in that column, and you get the error.

 Just switch those columns in one of the queries.

 James
0
 

Author Closing Comment

by:TomBalla
ID: 40345920
That was simple.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

729 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