Solved

Error creating command

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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 …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

13 Experts available now in Live!

Get 1:1 Help Now