日期:2014-05-17 浏览次数:20811 次
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_select_onlytime";
SqlParameter inparm1 = cmd.Parameters.Add("@start", SqlDbType.DateTime );
SqlParameter inparm2 = cmd.Parameters.Add("@end", SqlDbType.DateTime);
inparm1.Direction = ParameterDirection.Input;
inparm2.Direction = ParameterDirection.Input;
String FromDT = dtpfrdat.Value.ToString("yyyy-MM-dd")+" "+dtpfrtim.Value.ToString("HH:mm:ss");
DateTime temp1=Convert.ToDateTime(FromDT);
inparm1.Value = temp1;
String ToDT = dtptodat.Value.ToString("yyyy-MM-dd") + " "+dtptotim.Value.ToString("HH:mm:ss");
DateTime temp2=Convert.ToDateTime(ToDT);
inparm2.Value = temp2;
SqlDataReader rdr = cmd.ExecuteReader();
ALTER procedure [dbo].[sp_select_onlytime]
(@start datetime, @end datetime)
as
select
*
from
TestRecord
where
(TestTime >= CONVERT(VARCHAR(30),@start,121) and (TestTime <= CONVERT(VARCHAR(30),@end,121));