在我的应用程序中,我有 3 个记录不同的 report.rdlc 文件我正在使用选项按钮、复选框和组合框值的表单创建查询
string qry = "";
SqlCeConnection cnn = new
SqlCeConnection(Properties.Settings.Default.ConnectionString.ToString());
SqlCeCommand cmd = new SqlCeCommand();
if (radioButton1.Checked == true)
{
qry = @"Select Did,Cid,Source,Destination,Sid,cost,sdate,Driver.fname+' '+Driver.lname as driver,payed from Service,Driver where Service.Did=Driver.id";
}
else if (radioButton2.Checked == true)
{
button3.Enabled = true;
qry = @"Select Did,Cid,Source,Destination,Sid,cost,sdate,Driver.fname+' '+Driver.lname as driver,payed from Service,Driver where Service.Did=Driver.id and Did=@param ";
cmd.Parameters.Add("@param", CmbDriver.SelectedValue);
}
if (payedRB.Checked == true)
{
qry += @" and Service.payed=1";
}
else if (notpayedRB.Checked == true)
{
qry += @" and Service.payed=0";
}
if (txtDate1.Text != "" && txtDate2.Text != "")
{
qry += @" and Service.sdate between @pdate1 AND @pdate2";
cmd.Parameters.Add("@pdate1", SqlDbType.NVarChar, 20).Value = txtDate1.Text.Trim();
cmd.Parameters.Add("@pdate2", SqlDbType.NVarChar, 20).Value = txtDate2.Text.Trim();
state = 3;
}
else if (txtDate1.Text != "")
{
qry += @" and Service.sdate >= @pdate1";
cmd.Parameters.Add("@pdate1", SqlDbType.NVarChar, 20).Value = txtDate1.Text.Trim();
state = 1;
}
else if (txtDate2.Text != "")
{
qry += @" and Service.sdate <= @pdate2";
cmd.Parameters.Add("@pdate2", SqlDbType.NVarChar, 20).Value = txtDate2.Text.Trim();
state = 2;
}
if (activdr.Checked == true)
{
qry += @" and Driver.isActive=1";
}
else
{
qry += @" and Driver.isActive=0";
}
qry += @" ORDER BY Service.sdate desc,Service.Sid desc";
cmd.Connection = cnn;
cmd.CommandText = qry;
SqlCeDataAdapter adapter = new SqlCeDataAdapter(cmd);
cnn.Open();
adapter.Fill(dt);......
我在选项按钮事件中使用了 reporttype 变量来了解哪个报告将显示在报告查看器中。并将所选记录设置为数据网格查看器
我的报告从与记录字段兼容的临时表中获取数据。在此之前,我将所有记录(将在报表查看器中打印)插入到临时表中;
如何在没有临时表的情况下将记录传输到报告中;