在阜阳现场调试的时候,有一个电脑出现的打开报表时显示找不到方法“Void Microsoft.Reporting.PreviewItemContext.setbpath(System string,System string,Microsoft.Reporting.DefinitionSoure)”。
同一个安装包,只有一个电脑出现这个问题,怀疑是那台电脑缺少什么动态链接库,尴尬的是我不知道缺的什么。
对方电脑系统是Win7
代码编译器VS2005,
代码不是我敲的,前前前辈写的,我维护一下。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.SqlClient;
namespace ConcreteApp.report
{
public partial class MRSGMXBB : Form
{
private System.Data.SqlClient.SqlConnection con =
new System.Data.SqlClient.SqlConnection();
//-----配置数据库专用变量
private string ServerName = "";
private string DBName = "";
private string SqlName = "";
private string SqlPWD = "";
private string UID1;
private string sqlstr = "select QDDH 强度代号 from t_QDDH ";
public MRSGMXBB()
{
InitializeComponent();
}
private void MRSGMXBB_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“cDB_TEMPDataSet.t_shengchanrenwu”中。您可以根据需要移动或移除它。
this.t_shengchanrenwuTableAdapter1.Fill(this.cDB_TEMPDataSet.t_shengchanrenwu);
// TODO: 这行代码将数据加载到表“cDBDataSetIP.t_shengchanrenwu”中。您可以根据需要移动或移除它。
this.t_shengchanrenwuTableAdapter.Fill(this.cDBDataSetIP.t_shengchanrenwu);
this.reportViewer1.RefreshReport();
this.date1ToolStripTextBox.Text = DateTime.Now.ToShortDateString();
this.date2ToolStripTextBox.Text = DateTime.Now.AddDays(1).ToShortDateString();
string[] tmpcodeA;
UID1 = "";
try
{
//读取配置文件
using (StreamReader sr = new StreamReader(Application.StartupPath + "/config.ini"))
{
try
{
tmpcodeA = sr.ReadLine().Split('|');
this.ServerName = tmpcodeA[0].ToString();
this.DBName = tmpcodeA[1].ToString();
this.SqlName = tmpcodeA[2].ToString();
this.SqlPWD = tmpcodeA[3].ToString();
}
catch (Exception ex)
{
MessageBox.Show("读取配置文件失败!请检查程序目录下的config.ini文件。" + ex.ToString(), "提示");
}
}
//验证登陆
con.ConnectionString = ("SERVER=" + ServerName + ";UID=" + SqlName + ";PWD=" + SqlPWD + ";DATABASE=" + DBName + "");
con.Open();
SqlDataAdapter da = new SqlDataAdapter(sqlstr, con);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
CBpz.Items.Add(ds.Tables[0].Rows[i][0].ToString());
}
catch (Exception ex)
{
MessageBox.Show("数据库连接失败!请重新配置" + ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
}
private void fillBy1ToolStripButton_Click(object sender, EventArgs e)
{
if (CBpz.Text == "")
{
try
{
this.t_shengchanrenwuTableAdapter.FillBy(this.cDBDataSetIP.t_shengchanrenwu, date1ToolStripTextBox.Text, date2ToolStripTextBox.Text);
this.reportViewer1.RefreshReport();
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
else
{
try
{
this.t_shengchanrenwuTableAdapter.FillBy1(this.cDBDataSetIP.t_shengchanrenwu, date1ToolStripTextBox.Text, date2ToolStripTextBox.Text,CBpz.Text);
this.reportViewer1.RefreshReport();
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
}
}
}