Solved

Error creating command

Posted on 2014-09-25
2
124 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
2 Comments
 
LVL 34

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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 …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 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