我需要一些行。他们来自sql TARIH(sql列)是smalldatetime格式。但给我错误:DataRow [] rows = dsChart.Tables [0] .Select(“TARIH < ='”+ datestart +“”+ txtStartDateTime.Text +“'and TARIH > ='”+ dateend +“”+ txtEndDateTime的.text + “'”);如何使用sql查询从数据集中获取行?
无法对System.DateTime和System.String执行'< ='操作。
dsChart = eReport.ToDataSet();
if (txtStartDateTime.Text != "" && txtEndDateTime.Text != "")
if (ValidateHoursGap(txtStartDateTime.Text.Trim()) &&
ValidateHoursGap(txtEndDateTime.Text.Trim()))
{
DataRow[] rows = dsChart.Tables[0].Select("TARIH>='" + datestart + " " + txtStartDateTime.Text + "' and TARIH<='" + dateend + " " + txtEndDateTime.Text+"'");
dsChart.Tables[0].Rows.Clear();
dsChart.Tables[0].Rows.Add(rows);
}
这些是什么datestart和dateend变量?在数据集表达式中,日期必须如下格式化:“#05/27/2009#”或“#05/27/2009 10:33:51#” – 2009-05-27 12:26:21