我目前有这个代码用于填充DataSet和DataTables以在报告中加载它
public void load1()
{
string sql = "";
sql = "select customer,employee,service,price, DATE_FORMAT(`date`, '%Y-%m-%d') as asd from tbltransaction where CONCAT(customer,employee,service) LIKE '%" + textBox21.Text + "%' order by `date` desc;";
string constring = "server=localhost;database=dbhorizon;uid=root;password=1234";
MySqlConnection conn = new MySqlConnection(constring);
MySqlDataAdapter dataAdapter = new MySqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
dataAdapter.Fill(ds);
reportViewer1.Visible = true;
reportViewer1.Reset();
this.reportViewer1.LocalReport.DataSources.Clear();
ReportDataSource reportDataSource = new ReportDataSource();
reportDataSource.Value = ds.Tables[0];
reportDataSource.Name = "DataSet1";
this.reportViewer1.LocalReport.DataSources.Add(reportDataSource);
this.reportViewer1.LocalReport.ReportEmbeddedResource = "Services_and_Product_List.Report2.rdlc";
this.reportViewer1.RefreshReport();
}
这就是我触发load1()方法的地方
private void button1_Click(object sender, EventArgs e)
{
string sql = "";
if (textBox21.Text == "")
{
if (checkBox2.Checked == true)
{
load1();
}
}
这是我正在使用的表的构造
CREATE TABLE `tbltransaction` (`customer` varchar(50) DEFAULT NULL,
`employee` varchar(50) DEFAULT NULL,
`service` varchar(50) DEFAULT NULL,
`price` int(50) DEFAULT NULL,
`total` int(50) DEFAULT NULL,
`date` date DEFAULT NULL,
)
其他列(如employee等)在报表查看器中完美加载,但日期部分除外。这是输出
这是上面使用的sql代码的输出,存储在listview中并证明它运行正常
这可能是什么问题?我已经熬夜了28个小时来解决这个问题。推荐所有答案,我愿意提供更多详细信息。