从数据库中检索数据失败。详细信息:[数据库供应商代码:1370] 在 Crystal 报告中使用 ASP.ET
Failed to retrieve data from the database. Details: [Database Vendor Code: 1370 ] in Crystal Reports using ASP.ET
我看了很多,但没有找到任何解决办法。
我正在使用 Visual studio 2012,我的 Sql 作为数据库和 Crystal 报告。
我已经在 WINDOWS SERVER 2008 上部署了 Web 应用程序,当我从远程访问时,它会给我以下错误消息,如以下屏幕所示。
我正在使用以下代码
string databaseName = "hr";
string serverName = "192.168.137.6";
string userID = "userID";
string pass = "xxxxxxxxxxx";
protected void btn_search_Click(object sender, EventArgs e)
{
CrystalReportViewer1.Visible = true;
ReportDocument reportDocument = new ReportDocument();
string reportPath = Server.MapPath(@"~/GeneralEmpReports/test.rpt");
reportDocument.Load(reportPath);
reportDocument.SetParameterValue("D", tbx_ddoCode.Text.ToUpper());
reportDocument.SetDatabaseLogon(userID, pass, serverName, databaseName);
CrystalReportViewer1.ReportSource = reportDocument;
}
这里我想补充一点,如果我从 Tables 然后没有错误,完美执行。我已经通过 Navicat 工具(mysql 的 GUI 管理工具)检查了存储过程,它工作正常。
我通过控制面板==>管理工具==>数据源(ODBC)在服务器上添加了如下连接,如下图所示。
经过大量搜索后,我才知道我在服务器名称中做错了,
服务器名称应该是 DSN 名称而不是 IP 地址。在您的生产服务器上创建 System DSN 名称,与在开发计算机中给定的名称相同,如下所示。
数据源名称: DSN_Name
TCP/IP 服务器: 在开发 PC 中给它空白,这意味着 localhost 但在开发服务器中给出 IP 地址。
用户:用户名
密码:密码
数据库: 数据库名称
以下是运行良好的代码。
string databaseName = "hr";
string serverName = "hr_domain"; // DSN Name
string userID = "xxxxxxx";
string pass = "xxxxxxxx";
protected void btn_search_Click(object sender, EventArgs e)
{
CrystalReportViewer1.Visible = true;
ReportDocument reportDocument = new ReportDocument();
string reportPath = Server.MapPath(@"~/GeneralEmpReports/test.rpt");
reportDocument.Load(reportPath);
reportDocument.SetDatabaseLogon(userID, pass, serverName, databaseName);
reportDocument.SetParameterValue("D", tbx_ddoCode.Text.ToUpper());
CrystalReportViewer1.ReportSource = reportDocument;
}
我看了很多,但没有找到任何解决办法。 我正在使用 Visual studio 2012,我的 Sql 作为数据库和 Crystal 报告。 我已经在 WINDOWS SERVER 2008 上部署了 Web 应用程序,当我从远程访问时,它会给我以下错误消息,如以下屏幕所示。
我正在使用以下代码
string databaseName = "hr";
string serverName = "192.168.137.6";
string userID = "userID";
string pass = "xxxxxxxxxxx";
protected void btn_search_Click(object sender, EventArgs e)
{
CrystalReportViewer1.Visible = true;
ReportDocument reportDocument = new ReportDocument();
string reportPath = Server.MapPath(@"~/GeneralEmpReports/test.rpt");
reportDocument.Load(reportPath);
reportDocument.SetParameterValue("D", tbx_ddoCode.Text.ToUpper());
reportDocument.SetDatabaseLogon(userID, pass, serverName, databaseName);
CrystalReportViewer1.ReportSource = reportDocument;
}
这里我想补充一点,如果我从 Tables 然后没有错误,完美执行。我已经通过 Navicat 工具(mysql 的 GUI 管理工具)检查了存储过程,它工作正常。
我通过控制面板==>管理工具==>数据源(ODBC)在服务器上添加了如下连接,如下图所示。
经过大量搜索后,我才知道我在服务器名称中做错了, 服务器名称应该是 DSN 名称而不是 IP 地址。在您的生产服务器上创建 System DSN 名称,与在开发计算机中给定的名称相同,如下所示。
数据源名称: DSN_Name
TCP/IP 服务器: 在开发 PC 中给它空白,这意味着 localhost 但在开发服务器中给出 IP 地址。
用户:用户名
密码:密码
数据库: 数据库名称
以下是运行良好的代码。
string databaseName = "hr";
string serverName = "hr_domain"; // DSN Name
string userID = "xxxxxxx";
string pass = "xxxxxxxx";
protected void btn_search_Click(object sender, EventArgs e)
{
CrystalReportViewer1.Visible = true;
ReportDocument reportDocument = new ReportDocument();
string reportPath = Server.MapPath(@"~/GeneralEmpReports/test.rpt");
reportDocument.Load(reportPath);
reportDocument.SetDatabaseLogon(userID, pass, serverName, databaseName);
reportDocument.SetParameterValue("D", tbx_ddoCode.Text.ToUpper());
CrystalReportViewer1.ReportSource = reportDocument;
}