在 web.config 中使用水晶报表的连接字符串

发布于 2024-08-31 13:53:31 字数 303 浏览 2 评论 0原文

我在两台使用不同 odbc dsn 的服务器之间遇到问题。

我的应用程序运行良好,但 Crystal Reports 使用原始 odbc 连接,我该如何解决此问题?

我正在考虑在 web.config 中使用相同的连接字符串,但我不知道如何操作。

找到这个,但对我来说太混乱了,

谢谢,

I`m having problems between two servers, wich use differente odbc dsn.

My apps work great but crystal reports uses the original odbc connection, how can I fix this?

I'm thinking of using the same connection string in the web.config, but I don't know how.

found this but is too confusing for me

thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月寒剑心 2024-09-07 13:53:31

您不能像使用 ado.net 连接一样使用连接字符串。但是,您当然可以使用 web.config 中的值来指定连接信息。创建 ConnectionInfo 类的实例并设置 ServerName、DatabaseName、UserID 和 Password 属性。然后将其附加到报告中的每个表格中:

ConnectionInfo reportConnectionInfo = new ConnectionInfo();
reportConnectionInfo.ServerName = ConfigurationManager.AppSetting["ServerName"];
reportConnectionInfo.DatabaseName = ...;
reportConnectionInfo.UserID = ...;
reportConnectionInfo.Password = ...;

foreach (Table table in reportDocument.Database.Tables) {
  table.LogOnInfo.ConnectionInfo = reportConnectionInfo;
}

如果您尝试使用此建议,请注意我的草率打字...

You can't use a connection string in the same way you can with an ado.net connection. However, you can certainly use values from the web.config to specify the connection info. Create an instance of the ConnectionInfo class and set the ServerName, DatabaseName, UserID, and Password properties. Then attach it to each of the tables in the report:

ConnectionInfo reportConnectionInfo = new ConnectionInfo();
reportConnectionInfo.ServerName = ConfigurationManager.AppSetting["ServerName"];
reportConnectionInfo.DatabaseName = ...;
reportConnectionInfo.UserID = ...;
reportConnectionInfo.Password = ...;

foreach (Table table in reportDocument.Database.Tables) {
  table.LogOnInfo.ConnectionInfo = reportConnectionInfo;
}

If you try to use this suggestion, beware of my sloppy typing...

人事已非 2024-09-07 13:53:31

您可以使用连接字符串。
您必须创建数据库提供程序 ConnectionStringBuilder 的实例,传递从配置文件中提取的连接字符串。这是 VB 中的一个例子。

Dim connString As String = ConfigurationManager.ConnectionStrings["MyDbConn"].ConnectionString
Dim connStringBuilder As SqlConnectionStringBuilder = New SqlConnectionStringBuilder(connString)

Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
myConnectionInfo.DatabaseName = connectionStringBuilder.InitialCatalog
myConnectionInfo.UserID = connectionStringBuilder.UserID
myConnectionInfo.Password = connectionStringBuilder.Password
myConnectionInfo.ServerName = connectionStringBuilder.DataSource

You can use the connection string.
You have to create an instance of the database provider ConnectionStringBuilder passing in the Connection String pulled from a config file. Here is an example in VB.

Dim connString As String = ConfigurationManager.ConnectionStrings["MyDbConn"].ConnectionString
Dim connStringBuilder As SqlConnectionStringBuilder = New SqlConnectionStringBuilder(connString)

Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
myConnectionInfo.DatabaseName = connectionStringBuilder.InitialCatalog
myConnectionInfo.UserID = connectionStringBuilder.UserID
myConnectionInfo.Password = connectionStringBuilder.Password
myConnectionInfo.ServerName = connectionStringBuilder.DataSource
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文