1

I'm working on an existing .Net winforms application that has traditionally had crystal reports run against a LAN SQL Server database. I'm trying to get it working with an Azure cloud database.

The existing app uses the server name given by the user at login time to connect and set each table's location etc within the report so the report can be run against any database server rather than only work against the database the report was designed against. Hopefully this is a familiar concept for those who have used Crystal Reports in a windows app before as this is the second company I have worked for that has code similar to the following which loops through each table and sub report in the report to make sure they are all pointing at the specified server:

For Each crTable In crTables
        CrtableLogoninfo = crTable.LogOnInfo
        CrtableLogoninfo.ConnectionInfo = App._CrConnectionInfo
        crTable.ApplyLogOnInfo(CrtableLogoninfo)
        crTable.Location = App.DBName & ".dbo." & crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1)
    Next
    crSections = CrReportDocument.ReportDefinition.Sections
    For Each crSection In crSections
        crReportObjects = crSection.ReportObjects
        For Each crReportObject In crReportObjects
            If crReportObject.Kind = ReportObjectKind.SubreportObject Then
                crSubreportObject = CType(crReportObject, SubreportObject)
                subRepDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)
                crTables = subRepDoc.Database.Tables
                For Each crTable In crTables
                    CrtableLogoninfo = crTable.LogOnInfo
                    CrtableLogoninfo.ConnectionInfo = App._CrConnectionInfo
                    crTable.ApplyLogOnInfo(CrtableLogoninfo)
                    crTable.Location = App.DBName & ".dbo." & crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1)
                Next
            End If
        Next
    Next

This has been working for years against various LAN databases but doesn't seem to work with Azure. Crystal at runtime decides that the parameters that have been set by code need to be prompted for from the user, which seems to indicate something has gone wrong with the connection. If you enter parameter values it then errors complaining certain fields do not exist.

I've played about with various calls to _CrConnectionInfo.LogonProperties.Set("Connection String", "SomeConnectionString") immediately before the code above but at best it proceeds to a point where it says "Operation not yet implemented".

I tried from Crystal Reports directly to connect to the cloud and got that working using the SQL Server Client 11 connection type. In the application when I create an SQL client connection via a call to _CrConnectionInfo.LogonProperties.Set("Connection String", ""Provider=SQLNCLI;Server=tcp:theAzureDBInstanceName;Password=thePassword;Persist Security Info=True;User ID=thelogin;Initial Catalog=theDBName;Encrypt=yes;")") or some similar variation it still doesn't work.

Does anyone know how to get Crystal to connect to an Azure database directly from a .Net app? If you have code suggestions either VB.Net or C# samples are fine.

4

2 回答 2

0

Crystal Reports(即使是最新的 CR 2013 SP4)仍然不支持 Azure SQL。

来源:http ://scn.sap.com/thread/3430662

如果您在本地 MSSQL 数据库上设计报告,则可以在运行时在 Azure SQL 数据库上成功运行报告(前提是您正确设置了表位置),正如我在上面链接的线程中提到的那样 - 但如果您使用存储过程有一个警告 - 您必须关闭报告选项“第一次刷新时验证存储过程”。

如果您想要支持 Azure SQL,那么我敦促您对“创意场所”的想法进行投票:https ://ideas.sap.com/ct/ct_a_view_idea.bix?idea_id= {91C7DF6B-4BDA-4DB4-90DB-9695ADCCF09B }

我仍然对为什么 SAP 没有解决这个问题感到目瞪口呆。

注意:我发现自己使用 Crystal Reports 导致“操作尚未实现”的另一个常见原因是报表使用了客户端上不可用但在报表中使用的字体。“无效字体”消息会很好:)

于 2014-11-06T11:14:16.107 回答
0

这可能是由于不支持USE 语句造成的。您能否更改您的代码并确保:

  1. 连接字符串直接引用数据库:...;Initial Catalog=myDataBase;...
  2. 在您的代码中,替换App.DBName & ".dbo." & ...".dbo." & ...(尝试删除对数据库的任何直接引用)
于 2012-10-09T21:47:19.510 回答