Click here to Skip to main content
15,908,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
OleDbParameter DataTime_Join1 = new OleDbParameter(@DataTime_Join1, OleDbType.Date);
DataTime_Join1.Value = time1;
Command.Parameters.Add(DataTime_Join1);

OleDbParameter DataTime_Join2 = new OleDbParameter(@DataTime_Join2, OleDbType.Date);
DataTime_Join2.Value = time2;
Command.Parameters.Add(DataTime_Join2);

Command.CommandText ="select * from  table where DataTime_Join1>@DataTime_Join1 and DataTime_Join2<@DataTime_Join2";
Posted
Updated 23-Mar-13 12:12pm
v2
Comments
[no name] 23-Mar-13 18:16pm    
And the question is what?
Anderso0on 23-Mar-13 18:19pm    
what is syntax to selct item in range of datetime?

1 solution

Your query should looks like:
SQL
PARAMETERS dt1 DATE, dt2 DATE;
select * from  table where DataTime_Join1>#dt1# and DataTime_Join2<#dt2#

Then add parameters to command:
C#
OleDbCommand command = new OleDbCommand(commandText, connection);
command.CommandText = "^^^above query^^^"
command.Parameters.Add("dt1", OleDbType.Date);
command.Parameters["dt1"].Value = time1;
command.Parameters.Add("dt2", OleDbType.Date);
command.Parameters["dt2"].Value = time2;
 
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