0

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

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by LizR
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.