Click here to Skip to main content
16,020,249 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I try to select some records from my database by a column ho is Date/Time format compared with Datetima.Today. Im my database my format date time is "01/31/2014 07:10 PM", i wnat om my select to separate the date from time.

this is mi code. he gives no error but return 0 record.

C#
Program.Connection.CommandText = "select SUM(PretVanzare) AS PretVanzare, IIF(CatProdus Is Null, 0, CatProdus) AS CatProdus FROM ProduseVandute WHERE DataVanzare=@DataVanzare GROUP BY CatProdus";
                Program.Connection.AddParameter("@DataVanzare", DateTime.Today);
                DataTable TableNirProduseVandute = new DataTable();
                Program.Connection.FillDataTable(TableNirProduseVandute, true);

                decimal[] SoldProduseVandute = new decimal[TableNirProduseVandute.Rows.Count];
                int[] CatProdusNrVandut = new int[TableNirProduseVandute.Rows.Count];

                for (int i = 0; i < TableNirProduseVandute.Rows.Count; ++i)
                {
                    SoldProduseVandute[i] = Convert.ToDecimal(TableNirProduseVandute.Rows[i]["PretVanzare"].ToString());
                    CatProdusNrVandut[i] = Convert.ToInt32(TableNirProduseVandute.Rows[i]["CatProdus"].ToString());
                }
Posted
Comments
ZurdoDev 31-Jan-14 12:29pm    
I seem to recall Access needs # around the dates.
"select SUM(PretVanzare) AS PretVanzare, IIF(CatProdus Is Null, 0, CatProdus) AS CatProdus FROM ProduseVandute WHERE DataVanzare=#@DataVanzare# GROUP BY CatProdus";

1 solution

Run the query
<br />
"select SUM(PretVanzare) AS PretVanzare, IIF(CatProdus Is Null, 0, CatProdus) AS CatProdus FROM ProduseVandute WHERE DataVanzare=@DataVanzare GROUP BY CatProdus";

in access after replacing parameter with date and check if you get any results or not.
 
Share this answer
 

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