问题: 我要用C#来控制水晶报表里面的参数,也就是说不是报表做出来的时候就进行数据绑定的,是通过C#动态进行数据绑定的,听说VS.NET下面的安装目录有实例代码,但是我不知道放在那里了,谁要知道路径告诉我下也可以,
这是国际紧急求救,谁知道麻烦回帖(告诉我路径),或加QQ804206885 写明水晶报表
HELP NOW 再线等 本人不是特别笨,给个DEMO我一看 即可 ,立刻给分结贴 谢谢
再次声明是国际求救 HELP!!!!
这是国际紧急求救,谁知道麻烦回帖(告诉我路径),或加QQ804206885 写明水晶报表
HELP NOW 再线等 本人不是特别笨,给个DEMO我一看 即可 ,立刻给分结贴 谢谢
再次声明是国际求救 HELP!!!!
解决方案 »
- 当含参数委托作为其它函数参数时怎么添加委托方法实参
- Response.Redirect(url)这样跳转2级域名对搜索引擎友好不?可有什么好的解决方案?
- wcf性能问题,生产出现
- 求一个思路
- 弱弱的问一个问题,c#如何根据另一个类的某些内容修改一个form类中的控件信息
- 如何判断Vista下某个文件夹不可以保存文件,受到UAC的保护?
- 关于console输出的一个小问题
- 请问如何用C#处理麦克风输入和存储哪?谢谢
- 如何根据字符串的内容去实例化一个类?
- 大数据货物调配谁能给个算法思路
- c#如何向C++的DLL传递指针?
- 有没人做过Web应用界面框架里像C/S桌面程序里可以在一个父窗口内打开多个MDI窗体的?
那个dataset是强制类型,要用代码直接写怎么办? 还有就是 如果说参数和绑定的东西都有该怎么混合弄?
下面是我举的一个例子的代码部分namespace reportTest
{
public partial class _Default : System.Web.UI.Page
{
//绑定水晶报表
private void Page_Init(object sender, EventArgs e)
{
FillDropDownList();
SqlConnection con = new SqlConnection("Server=CHONG5;uid=sa;pwd=WXB94#gift;database=StoneERP");
con.Open();
string strSql = "SELECT * FROM Color";
SqlDataAdapter da = new SqlDataAdapter(strSql, con);
DataSetT ds = new DataSetT();
da.Fill(ds, "color");
con.Close(); ReportDocument rd = new ReportDocument();
rd.Load(Server.MapPath("CrystalReport1.rpt"));
rd.SetDataSource(ds);
this.CrystalReportViewer1.ReportSource = rd;
}//绑定下拉菜单
public void FillDropDownList()
{
SqlConnection con = new SqlConnection("Server=CHONG5;uid=sa;pwd=WXB94#gift;database=StoneERP");
con.Open();
string strSql = "SELECT [type] FROM Color GROUP BY [type]";
SqlCommand com = new SqlCommand(strSql, con);
SqlDataReader dr = com.ExecuteReader();
while (dr.Read())
{
ddlType.Items.Add(dr[0].ToString().Trim());
}
dr.Close();
con.Close();
}//搜索按钮
protected void btnLoad_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Server=CHONG5;uid=sa;pwd=WXB94#gift;database=StoneERP");
con.Open();
string strSql = "SELECT * FROM Color WHERE [Type] = '" + ddlType.SelectedValue.Trim() + "'";
SqlDataAdapter sda = new SqlDataAdapter(strSql, con);
DataSetT ds = new DataSetT();
sda.Fill(ds, "color");
con.Close();
ReportDocument rd = new ReportDocument();
rd.Load(Server.MapPath("CrystalReport1.rpt"));
rd.SetDataSource(ds);
this.CrystalReportViewer1.ReportSource = rd;
}
}
}DataSetT为数据集
m_strpath = Application.StartupPath;//获取系统的运行路径 logOnInfo = new TableLogOnInfo(); ReportDocument crystalReport1 = new ReportDocument();
crystalReport1.Load("水晶报表文件");
logOnInfo.ConnectionInfo.ServerName ="serverName" logOnInfo.ConnectionInfo.DatabaseName = "数据库名称" logOnInfo.ConnectionInfo.UserID ="用户"
logOnInfo.ConnectionInfo.Password =“口令”
crystalReport1.Database.Tables[0].ApplyLogOnInfo(logOnInfo);
crystalReport1.SetDataSource(mTable);//datatable
crystalReportViewer1.ReportSource = crystalReport1;
不知道有没有用处,供你参考,就是速度有点慢
{//push模式
CrystalReport1 newReport = new CrystalReport1();
string sql = "select * from student";
string strCon = "Data Source=.;Initial Catalog=studentManage;Integrated Security=True";
SqlConnection con = new SqlConnection(strCon);
con.Open();
SqlDataAdapter sda = new SqlDataAdapter(sql, strCon);
DataSet ds = new DataSet();
sda.Fill(ds, "students");
con.Close(); string strPath = Application.StartupPath;
strPath = strPath.Substring(0, strPath.LastIndexOf("\\"));
strPath = strPath.Substring(0, strPath.LastIndexOf("\\"));
strPath += @"\\CrystalReport1.rpt"; //repDoc.Load(strPath);
//repDoc.SetDataSource(ds.Tables["myWaiters"]);
newReport.Load(strPath);
newReport.SetDataSource(ds.Tables["students"]);
newReport.Refresh();
crOrder.ReportSource = newReport;
} private void btnPull_Click(object sender, EventArgs e)
{//pull模式
string strPath = Application.StartupPath;
strPath = strPath.Substring(0, strPath.LastIndexOf("\\"));
strPath = strPath.Substring(0, strPath.LastIndexOf("\\"));
strPath += @"\\CrystalReport1.rpt";
repDoc.Load(strPath);
repDoc.Refresh();
//repDoc.SetParameterValue("Title", "这是推模式的一个测试表!");
//repDoc.SetParameterValue("Parm", 1); crOrder.ReportSource = repDoc;
}