Crystal Reports changing oracle odbc connections at runtime
-
I have a problem. I have a report that in design time link with database with an odbc (Oracle provider). In runtime if i don´t change connection it works fine. My problem is that if i change de odbc (i try other odbc with other name but with same dns) at runtime, it doesn´t work. Only works if i change odbc connection in report at design time...but i need do it programtilly because i need user choose between two equals databases: real and testing. I try with code like Me.rptDoc.DataSourceConnections.Item(0).SetConnection("ODBCNAME", "", False) and other codes like that: Dim crConnectionInfo As ConnectionInfo Dim crDatabase As Database Dim crTables As Tables Dim crTableLogOnInfo As TableLogOnInfo Dim crReportDocument As ReportDocument = Me.rptDoc crDatabase = crReportDocument.Database crTables = crDatabase.Tables crConnectionInfo = New ConnectionInfo() crConnectionInfo.ServerName = "ODBCNAME" crConnectionInfo.DatabaseName = "" crConnectionInfo.UserID = "USER" crConnectionInfo.Password = "PASSWORD" For Each aTable As CrystalDecisions.CrystalReports.Engine.Table In crTables crTableLogOnInfo = aTable.LogOnInfo crTableLogOnInfo.ConnectionInfo.AllowCustomConnection = True crTableLogOnInfo.ConnectionInfo = crConnectionInfo aTable.ApplyLogOnInfo(crTableLogOnInfo) Next Could you help me?, thanks in advance Cristina
-
I have a problem. I have a report that in design time link with database with an odbc (Oracle provider). In runtime if i don´t change connection it works fine. My problem is that if i change de odbc (i try other odbc with other name but with same dns) at runtime, it doesn´t work. Only works if i change odbc connection in report at design time...but i need do it programtilly because i need user choose between two equals databases: real and testing. I try with code like Me.rptDoc.DataSourceConnections.Item(0).SetConnection("ODBCNAME", "", False) and other codes like that: Dim crConnectionInfo As ConnectionInfo Dim crDatabase As Database Dim crTables As Tables Dim crTableLogOnInfo As TableLogOnInfo Dim crReportDocument As ReportDocument = Me.rptDoc crDatabase = crReportDocument.Database crTables = crDatabase.Tables crConnectionInfo = New ConnectionInfo() crConnectionInfo.ServerName = "ODBCNAME" crConnectionInfo.DatabaseName = "" crConnectionInfo.UserID = "USER" crConnectionInfo.Password = "PASSWORD" For Each aTable As CrystalDecisions.CrystalReports.Engine.Table In crTables crTableLogOnInfo = aTable.LogOnInfo crTableLogOnInfo.ConnectionInfo.AllowCustomConnection = True crTableLogOnInfo.ConnectionInfo = crConnectionInfo aTable.ApplyLogOnInfo(crTableLogOnInfo) Next Could you help me?, thanks in advance Cristina
I has just the solution! I need to put a new line with table.location = "schemaName" & table.location after applylogoninfo! I found solution here: http://www.codecomments.com/Visual Basic Crystal Reports/message690985.html Thanks for all Cris