Dear All,
I am using a query as it is in SQL Server 2000 in my C# windows application.
The query is having name with "dbo" in all database object. If i remove that dbo from the name it is working fine. Why it is not working .net application ? What is the theory behind it. Please explain me..Thanks in advance.My query is given below.
strsql.Append("SELECT dbo.[Order].OrderID, dbo.Clients.CompanyName AS Customer,");
strsql.Append("dbo.Employee.LastName AS Employee, dbo.[Order].OrderDate, ");
strsql.Append("dbo.[Order].ShipmentDate, dbo.Clients_1.CompanyName AS Shipper, ");
strsql.Append("dbo.[Order].Freight,dbo.Clients.ClientID as CustomerID, ");
strsql.Append("dbo.Clients_1.ClientID as ShipperID FROM dbo.[Order] INNER JOIN ");
strsql.Append("dbo.Employee ON dbo.[Order].EmployeeID = dbo.Employee.EmployeeID INNER JOIN ");
strsql.Append("dbo.Clients ON dbo.[Order].CustomerID = dbo.Clients.ClientID INNER JOIN ");
strsql.Append("dbo.Clients Clients_1 ON dbo.[Order].ShipperID = Clients_1.ClientID ");
string sqlOrder = strsql.ToString();
Thanks,
Saji
1. Are the database objects actually in the dbo schema?
2. What do you mean by "not working" - an error? no results? incorrect results?
|||I noticed a posible problem in this lines:strsql.Append("dbo.[Order].ShipmentDate, dbo.Clients_1.CompanyName AS Shipper, ");
and
strsql.Append("dbo.Clients_1.ClientID as ShipperID FROM dbo.[Order] INNER JOIN ");
Clients_1 don't exists as a database object, but instead is an alias for Clients table, so you can't use this sintax when using in select statement. Just remove dbo. before Clients_1 and probably will be Ok:
strsql.Append("SELECT dbo.[Order].OrderID, dbo.Clients.CompanyName AS Customer,");
strsql.Append("dbo.Employee.LastName AS Employee, dbo.[Order].OrderDate, ");
strsql.Append("dbo.[Order].ShipmentDate, Clients_1.CompanyName AS Shipper, ");
strsql.Append("dbo.[Order].Freight,dbo.Clients.ClientID as CustomerID, ");
strsql.Append("Clients_1.ClientID as ShipperID FROM dbo.[Order] INNER JOIN ");
strsql.Append("dbo.Employee ON dbo.[Order].EmployeeID = dbo.Employee.EmployeeID INNER JOIN ");
strsql.Append("dbo.Clients ON dbo.[Order].CustomerID = dbo.Clients.ClientID INNER JOIN ");
strsql.Append("dbo.Clients Clients_1 ON dbo.[Order].ShipperID = Clients_1.ClientID ");
string sqlOrder = strsql.ToString();
|||Hi Boban,
Thank you so much..It is working well.
Regards,
Saji
No comments:
Post a Comment