Connecting Tech Pros Worldwide Help | Site Map

Crystal Report connection to SQL vb.net in Visual Studio 2008

 
LinkBack Thread Tools Search this Thread
  #1  
Old January 7th, 2009, 04:46 PM
Newbie
 
Join Date: Aug 2008
Location: Orlando, FL
Age: 26
Posts: 13
Default Crystal Report connection to SQL vb.net in Visual Studio 2008

My Crystal Report is pulling information from a stored procedure I wrote. So everytime I run my application it prompts me for a password for the server. How do I bypass this step and hardcode the password into my application. I don't want my users knowing the password for the server. I am writing in vb.net using visual studio 2008.
Reply
  #2  
Old January 15th, 2009, 08:44 AM
OuTCasT's Avatar
Needs Regular Fix
 
Join Date: Jan 2008
Location: South Africa
Posts: 313
Default

You need to send the UserID and Password to the report. so it wont ask you for it when u run it.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim report As New ReportDocument
  3. Dim connection As IConnectionInfo
  4. Dim oldServerName As String = ".\SQLEXPRESS"
  5. Dim oldDatabaseName As String = "Old DatabaseName"
  6. Dim newServerName As String = strOldServerName
  7. Dim newDatabaseName As String = strCompanyName
  8. Dim UserID As String = ""
  9. Dim Password As String = ""
  10.  
  11. report.Load(Application.StartupPath + "\Reports\example.rpt")
  12. CrystalReportViewer1.ReportSource = report
  13. 'Change the server name and database in main report
  14. For Each connection In report.DataSourceConnections
  15. report.DataSourceConnections(oldServerName, oldDatabaseName).SetConnection(newServerName, newDatabaseName, UserID, Password)
  16. Next
  17. 'Change the server name and database subreports
  18. Dim subreport As ReportDocument
  19. For Each subreport In report.Subreports
  20. For Each connection In subreport.DataSourceConnections
  21. If (String.Compare(connection.ServerName, oldServerName, True) = 0 _
  22. And String.Compare(connection.DatabaseName, oldDatabaseName, True) = 0) Then
  23. subreport.DataSourceConnections(oldServerName, oldDatabaseName).SetConnection(newServerName, newDatabaseName, UserID, Password)
  24. End If
  25. Next
  26. Next
  27. CrystalReportViewer1.RefreshReport()
  28.  
Reply
Reply

Bookmarks

Tags
crystal reports

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.