Click here to Skip to main content
16,020,305 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello guys.

I have a problem with the sql query in C# :(.

here is the code:

C#
dts.Tables.Clear();
           
SqlDataAdapter da = new SqlDataAdapter("SELECT t.Date, t.Barcode, t.Name, t.Quantity, d.BuyPrice, t.SellPrice FROM tblSales t, tblMagazine d WHERE t.Date BETWEEN '" + DateTimePicker1.Value + "' AND '" + DateTimePicker2.Value + "'", con);

da.Fill(dts);

dataGridView1.DataSource = dts.Tables[0];


It gives me cartesian product or something like that.... because when I click the button (that has this code) it shows me more tables than I have in the table Sales.

What is the problem ?? Can someone help me
Posted
Updated 20-Jan-13 18:18pm
v2
Comments
[no name] 20-Jan-13 23:55pm    
Please send me the exact error you got..
Sergey Alexandrovich Kryukov 21-Jan-13 0:15am    
And what's the problem? You don't what Cartesian product or what? What do you want to achieve, exactly?
—SA

1 solution

tblSales and tblMagazine don't have something in common... you're right about the cartesian;

What's the link between Sales and Magazine, due this one's missing.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900