Good Evening alL

I have an ASP.NET Front end that seaches the Dates in certain Ranges. here is my Data Layer.

public DataTable Get_Date_by_Month(String Username,String Datefrom, String Dateto)
        {
            con = new OleDbConnection(strcon);

            DataTable Details = new DataTable();
            
            da = new OleDbDataAdapter();

            cmdselect = new OleDbCommand();

            cmdselect.CommandTimeout = 0;
            
            cmdselect.CommandText = "SELECT [Details].[Transportation],[Details].[HOUSING], [Details].[FEEDING], [Details].[UTILITIES], [Details].[INSURANCE],[Details].[TELECOMMUNICATION],[Details].[Entertainment],[Details].[FUEL],[Details].[CLOTHING],[Details].[EDUCATION],[Details].[Miscellaneous],[Details].[BASIC_INCOME], [Details].[OTHER_INCOME] FROM [Details] INNER JOIN USERS  ON Details.[P_ID] = [USERS].[ID] Where Details.Username = ? And Details.[DATE] Between  ?  AND ? ";
            
            cmdselect.CommandType = CommandType.Text;

            cmdselect.Connection =con;

            da.SelectCommand = cmdselect;

            da.SelectCommand.Parameters.Add("[Username]", OleDbType.VarChar, 30).Value = Username;
           
            da.SelectCommand.Parameters.Add("[DATE]",OleDbType.Date, 30).Value = Convert.ToDateTime(Datefrom).ToShortTimeString();

            da.SelectCommand.Parameters.Add("[DATE]", OleDbType.Date, 30).Value = Convert.ToDateTime(Dateto).ToShortTimeString();

             
            try
            {
                con.Open();

                Details.Clear();

                da.Fill(Details);
                

            }
            catch(OleDbException)
            {
                throw;
            }
            finally
            {
                con.Close();
            }
            return Details;
        }

but now if i try to Search between Valid Ranges, it Brings nothing to the DAtagrid. Am Using Access 2003Thanks

At first glance the one thing that comes to mind is that the date parameters, are you sure its creating the correct select statement? in terms of, it potentially could be not placing the date values where you think.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.