实际上我有一个查询,它在一行中为每个或它们返回 5 个列和值(日期),但我想要的是列名应该在一个列中Title
,并且它的(Vale)在Date
.
注意Title
和Date
是我刚刚创建运行时的临时表的列。
这是我正在使用的一段代码,
protected void btnAlerts_Click(object sender, EventArgs e)
{
fnSaveAlerts();
}
private void fnSaveAlerts()
{
DataTable dtTemp = new DataTable();
DataColumn dtC1 = new DataColumn();
dtC1.DataType = typeof(String);
dtC1.ColumnName = "Title";
DataColumn dtc2 = new DataColumn();
dtc2.DataType = typeof(DateTime);
dtC1.ColumnName = "Date";
dtTemp.Columns.Add(dtC1);
dtTemp.Columns.Add(dtc2);
LeadsContracts ObjLeadsContract = new LeadsContracts();
ObjLeadsContract.ExecuteSql(@"select dtDisclosure, dtDueDiligence,
dtFinanceAppraisals, dtFreeTextDate1,
dtFreeTextDate2
from LeadsContracts
where dtDisclosure is not null
and dtDueDiligence is not null
and dtFinanceAppraisals is not null
and dtFreeTextDate1 is not null
and dtFreeTextDate2 is not null");
dtTemp.DataSet = ObjLeadsContract.DefaultView; // it also gives error here "Red line"
}
我已经花了一整天的时间来做这件事,请任何人都可以帮助我。提前致谢