C#水晶报表在32位2003下正常,但在64位2003下异常
如题,同样的程序在32位的2003下正常,但在64位的2003下,调试报错,行号156为SetCurrentValuesForParameterField方法的最后一行:System.Runtime.InteropServices.COMException (0x80042002): 未找到浏览字段
在 CrystalDecisions.ReportAppServer.Controllers.ParameterFieldControllerClass.SetCurrentValues(String ReportName, String ParameterFieldName, Values Values)
在 CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition.ApplyCurrentValues(ParameterValues currentValues)
在 CS_Base.Form1.SetCurrentValuesForParameterField(ReportDocument reportDocument, ArrayList arrayList) 位置\Form1.cs:行号 156
在 CS_Base.Form1.Form1_Load(Object sender, EventArgs e) 位置 Form1.cs:行号 113
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using EXPORTDate;
using System.IO;
using System.Collections;
using System.Data.OleDb;
namespace CS_Base
{
public partial class Form1 : Form
{
private ReportDocument customersByCityReport;
private const string PARAMETER_FIELD_NAME = "area";
public static string areastr;
private string exportPath;
private DiskFileDestinationOptions diskFileDestinationOptions;
private ExportOptions exportOptions;
private bool selectedNoFormat = false;
public string CONNECTION_STRING = "Provider=MSDAORA.1;Password=123456;User ID=hwrpt;Data Source=192.168.0.215;Persist Security Info=True";
public const string QUERY_STRING="";
public Form1()
{
InitializeComponent();
}
public class DataSetConfiguration
{
public const string CONNECTION_STRING = "Provider=MSDAORA.1;Password=123456;User ID=hwrpt;Data Source=192.168.0.215;Persist Security Info=True";
private const string DATATABLE_NAME = "vw_hr_hq_wages7";
private const string DIRECTORY_FILE_PATH = "";
public static DataSet CustomerDataSet
{
get
{
bool isError = false;
string QUERY_STRING = "SELECT * FROM vw_hr_hq_wages7 where area='" + areastr + "'";
CustomerDataSetSchema dataSet = new CustomerDataSetSchema();
OleDbConnection oleDbConnection = new OleDbConnection(CONNECTION_STRING);
oleDbConnection.Open();
OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(QUERY_STRING, oleDbConnection);
oleDbDataAdapter.Fill(dataSet, DATATABLE_NAME);
oleDbConnection.Close();
return dataSet;
}
}
}
private void ConfigureCrystalReports()
{
customersByCityReport = new ReportDocument();
string reportPath = Application.StartupPath + "\\" + "EXPORTday.rpt";
customersByCityReport.Load(reportPath);
DataSet dataSet = DataSetConfiguration.CustomerDataSet;
ArrayList arrayList = new ArrayList();
arrayList.Add(textBox1.Text.ToString());
SetCurrentValuesForParameterField(customersByCityReport, arrayList);
customersByCityReport.SetDataSource(dataSet);
crystalReportViewer.ReportSource = customersByCityReport;
}
public void Form1_Load(object sender, EventArgs e)
{
{
OleDbConnection oleDbConnection = new OleDbConnection(CONNECTION_STRING);
oleDbConnection.Open();
string sqlstrstr00175 = "select smalldeptid,bigdeptid,pay_month from HR_HQ_WAGES_XLSX_CFG where bigdeptid<>'as速运'";
OleDbCommand commandstravg00175 = new OleDbCommand(sqlstrstr00175, oleDbConnection);
OleDbDataReader readerCenterstrday00175 = commandstravg00175.ExecuteReader();
try
{
while (readerCenterstrday00175.Read())
{
if (!readerCenterstrday00175.IsDBNull(0) || !readerCenterstrday00175.IsDBNull(1))
{
textBox1.Text = readerCenterstrday00175.GetString(0);
areastr = readerCenterstrday00175.GetString(0);
textBox2.Text = readerCenterstrday00175.GetString(1);
textBox3.Text = readerCenterstrday00175.GetString(2);
{
//start201309
ConfigureCrystalReports();
ArrayList arrayList = new ArrayList();
arrayList.Add(textBox1.Text);
SetCurrentValuesForParameterField(customersByCityReport, arrayList);
crystalReportViewer.ReportSource = customersByCityReport;
exportTypesList.DataSource = System.Enum.GetValues(typeof(ExportFormatType));
ExportSetup();
ConfigureExportToXls();
ExportCompletion();
customersByCityReport.Dispose();
//end201309
}
}
}
}
catch (Exception readerCenterstravg00175)
{
MessageBox.Show(readerCenterstravg00175.ToString());
readerCenterstrday00175.Close();
}
}
timer1.Enabled = true;
}
private void crystalReportViewer_Load(object sender, EventArgs e)
{
}
private void SetCurrentValuesForParameterField(ReportDocument reportDocument, ArrayList arrayList)
{
ParameterValues currentParameterValues = new ParameterValues();
foreach (object submittedValue in arrayList)
{
ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
parameterDiscreteValue.Value = submittedValue.ToString();
currentParameterValues.Add(parameterDiscreteValue);
}
ParameterFieldDefinitions parameterFieldDefinitions = reportDocument.DataDefinition.ParameterFields;
ParameterFieldDefinition parameterFieldDefinition = parameterFieldDefinitions[PARAMETER_FIELD_NAME];
parameterFieldDefinition.ApplyCurrentValues(currentParameterValues);
}
private ArrayList GetDefaultValuesFromParameterField(ReportDocument reportDocument)
{
ParameterFieldDefinitions parameterFieldDefinitions = reportDocument.DataDefinition.ParameterFields;
ParameterFieldDefinition parameterFieldDefinition = parameterFieldDefinitions[PARAMETER_FIELD_NAME];
ParameterValues defaultParameterValues = parameterFieldDefinition.DefaultValues;
ArrayList arrayList = new ArrayList();
foreach (ParameterValue parameterValue in defaultParameterValues)
{
if (!parameterValue.IsRange)
{
ParameterDiscreteValue parameterDiscreteValue = (ParameterDiscreteValue)parameterValue;
arrayList.Add(parameterDiscreteValue.Value.ToString());
}
}
return arrayList;
}
private void timer1_Tick(object sender, EventArgs e)
{
Application.Exit();
}
}
} 64位 异常 --------------------编程问答-------------------- 右键项目->属性->生成->目标平台:选择x64。 --------------------编程问答-------------------- 哪位大侠能够帮忙看看,在32位上真的没有问题,今天还把32位上的程度复制到64位上调试还是不行.一开始数据库连不上,用微软的连接,后面网上说在项目的选项输出的地方收any 改为x86后,数据库是连通了,但调试的时候就是这个地方出错了.谢谢. --------------------编程问答-------------------- 右键项目->属性->生成->目标平台:选择x64。
我试试.稍候. --------------------编程问答-------------------- 右键项目->属性->生成->目标平台:选择x64。
我选择后,的确没有报错了,但我原先写在 public void Form1_Load(object sender, EventArgs e)
{}这个中的这一段都没有执行,就显窗口界面出来了哟,我是在Load的过程中做了很多操作,然后就触发Timer1自动退出的.不知道这个是? --------------------编程问答-------------------- 除
补充:.NET技术 , C#