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.