Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using LEFT JOIN in C#

Status
Not open for further replies.

ThomasBB

IS-IT--Management
Mar 9, 2010
89
DK
Hello!

I have a question, which might or might not be stupid :) Hope you can help me..

Basically, I'm trying to make a small application (only to be used by me) that can download data from our Navision-database and convert it into a format that our distribution-company can understand. Currently I'm doing it manually, so it would help me loads, if I could get this thing working.

I'm pretty new to SQL and C# - have only done minor projects here and there, mostly in school.

Anywho! On to the code in question:

SQLData = "SELECT [Customer No_], Name, [Name 2], Address, [Address 2], [Post Code], City, [Country_Region Code] "+
"FROM [Department - Company$Ship-to Address] " +
"LEFT JOIN [Department - Company$Customer] " +
"ON [Department - Company$Ship-to Address.Customer No_] = [Department - Company$Customer.No_] " +
"WHERE [Department - Company$Ship-to Address.Last Date Modified] >= '" + dato + "' " +
"OR [Department - Company$Customer.Last Date Modified] >= '" + dato + "'";


There's two different tables (one with shipping-address and one with invoice-address). The SQL itself works like it's supposed to - at least when I tested it with my SQL-client.

It just doesn't work in C# for some reason. As you can see, the table-names are a bit iffy, meaning I have to use brackets to "keep them together".

Running the code above gives me an exception, claiming that "Department - Company$Ship-to address.Customer No_" is an invalid column. Also there are three other columns which supposedly are invalid.

If I remove the LEFT JOIN part and only download data from one table it works like it's supposed to... I'm really at a loss here!

can anyone help me?

Thank you in advance!

/Thomas
 
Nevermind this.. Got pointed in the right direction :)

ON [Department - Company$Ship-to Address.Customer No_]

Should be

ON [Department - Company$Ship-to Address].[Customer No_]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top