Data Connectivity
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Data Connectivity
Message Icon Topic: Changing the location of a data source Post Reply Post New Topic
Author Message
Francoiscms
Newbie
Newbie


Joined: 24 Jul 2008
Online Status: Offline
Posts: 4
Quote Francoiscms Replybullet Topic: Changing the location of a data source
    Posted: 24 Jul 2008 at 1:02am
Hi,
Regarding the chapter of ur book http://members.crystalreportsbook.com/books/?p=822

I am trying to change the data source at runtime so I’ve used the above method in my application.(i use C#, with an oledb connection to sql 2005 express)

Everything seems fine, no errors etc. but when I run my application on a clients machine and i change the data source values, the values somehow aren’t being changed and i get a pop up window asking me for a user name and password to log into the database.

The server name/ip and database name fields are disabled and the values in there are those values assigned to my actual reports data location I’ve set through the designer/wizard in visual studio 2008.
How can this be fixed?


IP IP Logged
Francoiscms
Newbie
Newbie


Joined: 24 Jul 2008
Online Status: Offline
Posts: 4
Quote Francoiscms Replybullet Posted: 28 Jul 2008 at 4:07am
Any help please!
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 29 Jul 2008 at 2:56pm
Do you have a subreport in your report?  Also, not everyone on the forum has access to the link that you provided - please post your code.
 
Thanks!
 
-Dell
IP IP Logged
Francoiscms
Newbie
Newbie


Joined: 24 Jul 2008
Online Status: Offline
Posts: 4
Quote Francoiscms Replybullet Posted: 30 Jul 2008 at 12:52am
I dont have any subreports in my reports.
Here is the code i am testing at the moment:

         CrystalDecisions.CrystalReports.Engine.ReportDocument myReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            myReport.Load(@reportPath);
            Database crDatabase;
            Tables crTables;
            CrystalDecisions.CrystalReports.Engine.Table crTable;
            TableLogOnInfo crTableLogOnInfo;
            ConnectionInfo crConnectionInfo = new ConnectionInfo();
            crConnectionInfo.ServerName = INIFile.IniReadValue("Server", "Server").ToString();
            crConnectionInfo.DatabaseName = INIFile.IniReadValue("DBName", "DBName").ToString();
            crConnectionInfo.UserID = INIFile.IniReadValue("UName", "UName").ToString();
            crConnectionInfo.Password = INIFile.IniReadValue("PWord", "PWord").ToString();
            crDatabase = myReport.Database;
            crTables = crDatabase.Tables;
            for (int i = 0; i < crTables.Count; i++)
            {
                crTable = crTables;
                crTableLogOnInfo = crTable.LogOnInfo;
                crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                crTable.ApplyLogOnInfo(crTableLogOnInfo);
                crTable.Location = "" +
                crTable.Location.Substring(crTable.Location.LastIndexOf
                (".") + 1);
            }
            crystalReportViewer1.ReportSource = myReport;


I receive the following error:
Logon failed.
Details: ADO Error Code: 0x
Source: Microsoft OLE DB Provider for SQL Server
Description: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
SQL State: 08001
Native Error:

I receive this error on the following row:
for (int i = 0; i < crTables.Count; i++)
with the "i++" highlighted as the problem

Also since i tried to change the datasource at runtime, everything is working so slow. Report usually takes up to a minute to throw up an error.

Thanks
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 30 Jul 2008 at 7:41am
That is an odd error.  It looks like the computer/user ID where this is running needs to have access to both the original database location and the new one.
 
Brian, Have you seen this before?
 
-Dell
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 31 Jul 2008 at 11:17am
I saw this on the members-only section and to be honest, I don't have the answer for it. The only time I've seen this is when the user doesn't have rights to connect to the database. People will insist that everything is fine and the security has been setup, but then a week later will come back to report that the admin changed something and didn't realize it. But this is difficult to figure out over the forum b/c there is a lot involved in checking credentials on an other server.
 
What I would do is setup another database on your test server and give it a new name. Then run this code against that database and see if it works. If it does, and I expect it to b/c it looks fine, then that means that the user trying to access the production database doesn't have proper access for whatever reason.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
Francoiscms
Newbie
Newbie


Joined: 24 Jul 2008
Online Status: Offline
Posts: 4
Quote Francoiscms Replybullet Posted: 01 Aug 2008 at 12:34am
Thanks for the reply, I have decided to rather go for the push method by using datasets and schema's, works great.
Using your solution would cause to many difficulties on our clients side, but good to know what can be done to fix this.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.020 seconds.