473,382 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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.
Jan 7 '09 #1
1 12687
OuTCasT
374 256MB
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.  
Jan 15 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Stephan | last post by:
Hi, I'm using Visual Studio 2003 (C#) with the integrated Crystal Report software and have the following question: How can I assign a value (string) to an unbound (string) field in Crystal...
6
by: Dr. Indera | last post by:
hello, much to my surprise, the version of crystal that comes with visual studio.net 2003 does not have a report preview window. i found out that i have to build a form in visual basic.net and...
2
by: GC | last post by:
HI, I'am using Crystal Report with visual Studio .NEt 2003 When i make a report using a store procedure, I can not see all the fields of the store proc and i'm suppose to see those fields. I'm...
0
by: SWu | last post by:
Hi all Could someone please tell me how to configure and deploy my Crystal reports? Any help would be greatly appreciated. I want to be able to deploy my reports/web pages to another domain,...
11
by: =?Utf-8?B?cmtibmFpcg==?= | last post by:
How can I stop receiving this message while calling a crystal report? "The report you requested requires further information." Thanks
1
Shashi Sadasivan
by: Shashi Sadasivan | last post by:
Hi, I have bumped into this issue where my application (which consistently reads the database) has to also create a crsytal report when requested. The crystal repost uses the same connection string...
6
by: Miro | last post by:
I can run an exe ( and its install ) i have created on my machine. The exe has a button that populates a dataset and then shoots it to a crystal report. But... Installing the setup.exe on my...
4
by: Miro | last post by:
<i have also added this reply to the other newsgroup - now that I have realizd ( and assuming ) it is not a localized error directly to vb.> I have found this link on the website:...
1
by: =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?= | last post by:
On reflection, you could possibly make the app a self extracting zip file which extracts the EXE and a settings file and then starts the app, then when you app closes, it can repack the settings...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.