You can either specify the tablename only orĬrTable.location = "" Important that you specify the table location after youĪpply logon information (this is a case sensitive + If you are changing database at runtime, it is
You do not specify or call the DataBind in your code as + If you're using a web application make sure that, you should have the following line of code:ĬrTable.Location = crConnectionInfo.DatabaseName + ".dbo." +Ĭ( off of a Northwind database on SQL server If your DatabaseName is changing at runtime, specify Loop through all tables in the report and apply theĬrTable.ApplyLogOnInfo(crTableLogOnInfo) Get the table information from the report This code works for both user tables and stored crConnectionInfo.DatabaseName = "" ĬrConnectionInfo.DatabaseName = "DatabaseName" ĬrConnectionInfo.Password = "Your Password" If you are connecting to Oracle there is no OLEDB, etc, this should be the physical server name If using ODBC, this should be the DSN. to log on to the data source for the report. Setup the connection information structure Private ConnectionInfo crConnectionInfo = new
Private CrystalReport1 crReportDocument = new 'Set the viewer to the report object to be previewed.ĬrystalReportViewer1.ReportSource = crReportDocument 'For example, when you are reporting off of aĬrTable.Location = crConnectionInfo.DatabaseName & ".dbo." &Ĭ(( 'If your DatabaseName is changing at runtime, specify 'Loop through each table in the report and apply the
Set the CrTables to the Tables collectionĬrTables = 'This code works for both user tables and stored 'If you are connecting to Oracle there is no 'you are NOT using ODBC, this should be the 'If you are using ODBC, this should be theĭSN name NOT the physical server name. 'Set the ConnectionInfo properties for logging on to 'loading a report outside of the project, use theĭim crReportDocument As New ReportDocument()ĬrReportDocument.Load("c:\myReports\myReport.rpt") 'If you are using a Non-Typed report, and 'your project) named CrystalReport1.rpt use theĭim crReportDocument As New CrystalReport1() 'If you are using a Strongly Typed report (Imported in Imports ĭim crtableLogoninfos As New TableLogOnInfos()ĭim crtableLogoninfo As New TableLogOnInfo()ĭim crConnectionInfo As New ConnectionInfo() To pass logon information to a Crystal Report at How do you pass database logon information to a Crystal Report at runtime in this VB. I noticed that it is a most common problem which most of the developer face in development. The main purpose of this article is to explain how we change logon information of our reports to run them with different databases. When we design reports in Crystal Report designer, it fixs the complete information about Database location with table or stored procedures and if we want to run same reports with different datasource then we have to change logon information and as well as the location of the database.