Solved

Error creating command

Posted on 2014-09-25
2
120 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now