Filtering by DateTime datatypes

  • Thread starter Thread starter Marc
  • Start date Start date
M

Marc

I need to read and filter data from a data table on a remote sql
server. The data needs to be filtered by a column DateTimeIn. I need
to filter a week's worth of information depending on what a user
inputs as the StartingDate.

I'm using C# and what I've done is the following:
- I created a SqlDataAdapter that connects to the remote data table.
- I figured I'd begin by only retrieving information for a particular
date and not a range.
- But this itself hasn't worked.
- For some odd reason I can't filter data from a column with a
DateTime datatype.
- I can filter by any of the other columns.
- This is my first hurdle.
Does anyone know how one can filter from a DateTime column?

Here's my Select Command.........

this.sqlSelectCommand1.CommandText = "SELECT Identity, BadgeNo,
PayCode, DateTimeIn, DateTimeOut, Source, CreateDate, RevisedDate FROM
TransactionData WHERE (DateTimeIn = @Param9)";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
this.sqlSelectCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Param9",
System.Data.SqlDbType.DateTime, 8, "DateTimeIn"));

and here's where I set @Param9 equal to my text box value, clear and
fill my dataset:

sqlDataAdapter1.SelectCommand.Parameters["@Param9"].Value =
txtDateParameter1.Text;
dsTimeIn1.Clear();
sqlDataAdapter1.Fill(dsTimeIn1);

Why does this not work with DateTime datatypes? I've tried it with
every other datatype in the table and it works fine then.

Does anyone have any clue on how to fix this?
 
Back
Top