?
Solved

Error creating command

Posted on 2014-09-25
2
Medium Priority
?
128 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 2000 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

752 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