on 06-02-2011 4:44 PM
I am trying to write an interface for users to view Crystal Report and the users no need to enter database login user name and password.The report gets data from Visual FoxPro and Microsoft SQL Server via ODBC.
I use ReportDocument to load the report. use this fragment to put username password in IConnectionInfo
Dim myDataSourceConnections As DataSourceConnections = northwindCustomersReport.DataSourceConnections
For Each myConnectInfo As IConnectionInfo In myDataSourceConnections
If myConnectInfo.ServerName = "database" Then 'SQL Server
myConnectInfo.SetLogon("username", "password")
ElseIf myConnectInfo.ServerName = "database2" Then 'Visual FoxPro
myConnectInfo.SetConnection("database2", "", "", "")
End If
Next
When I run the program, it keeps asking the username and password for VFP but VFP connection doesn't need any. If I just click "OK", and it said failed to login.
Please advise.
Thanks.
It might be that the database file is in a different location on the client system. You can confirm where the application is looking for the db file by using Process Monitor. If you find it is looking in a spot that is different than you expect you'll be closer to a solution.
The IConnectionInfo.SetConnection() method should allow you to modify the location of the database file. But if not, you could go back to the other method of accessing the ReportDocument.Database.Tables collection. Then loop through each Table and update the ConnectionInfo with new values, then finally call the SetTableLocation for each table.
Search for SetTableLocation in the knowledgebase and you'll get quite a few hits.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.