
March 18th, 2003, 09:48 PM
|
|
Contributing User
|
|
Join Date: Nov 2001
Location: USA
Posts: 312
Time spent in forums: 3 h 27 m 43 sec
Reputation Power: 7
|
|
|
ADO.NET and SQL Queries
I am trying to do a join with ADO.NET. I have tested this Query is both Access and SQL Server and it works fine so I am thinking I missed something on my form. Here is the query it ain't pretty and may not be the best way to do it but it works. I think my error has to be something with the connection on my VB.NET form. It is one of those errors that drive you nuts cause the solution will probably have nothing to do with the query.
PHP Code:
SELECT Sales.SalesID, Sales.WinningBid, Items.Location, Items.Description, Bidder.BidderNumber, Bidder.Name, Bidder.Address, Bidder.City, Bidder.State, Bidder.Zip, Bidder.Phone
FROM (Bidder INNER JOIN Sales ON Bidder.BidderNumber = Sales.BidderNumber) INNER JOIN Items ON Sales.ItemLocation = Items.Location
WHERE (Sales.BidderNumber = '1')
Here is my error if it helps at all.
PHP Code:
Syntax error (missing operator) in query expression 'Bidder.BidderNumber = Sales.BidderNumber INNER JOIN Items ON Sales.ItemLocation = Items.Location'.
Now what I have found out is if you use the DataAdapter control it does not do multiple joins really well. What I had to do is program this through code with out controls. When I added the multiple join to the DataAdaper it would rewrite it like this.
PHP Code:
SELECT Sales.SalesID, Sales.WinningBid, Items.Location, Items.Description, Bidder.BidderNumber, Bidder.Name, Bidder.Address, Bidder.City, Bidder.State, Bidder.Zip, Bidder.Phone
FROM Bidder INNER JOIN Sales ON Bidder.BidderNumber = Sales.BidderNumber INNER JOIN Items ON Sales.ItemLocation = Items.Location
WHERE (Sales.BidderNumber = '1')
This would give me the error stated above. So if you are having trouble getting more complex SQL Queries to work with the DataAdapter you may nee to skip the easy way out and do this through code and it should work just fine.
Last edited by iamtgo3 : March 20th, 2003 at 08:22 AM.
|