Solved

.net crystal report change datasource

Posted on 2008-06-14
9
1,691 Views
Last Modified: 2010-04-21
How to change datasource for a crystal report between databases also pass login and password
0
Comment
Question by:tnasca
  • 3
  • 2
  • 2
  • +1
9 Comments
 

Author Comment

by:tnasca
ID: 21786425
How to change datasouece for a crystal report between databases also pass login and password
0
 

Author Comment

by:tnasca
ID: 21786427
How to change datasouece for a crystal report between databases also pass login and password
0
 
LVL 31

Expert Comment

by:James Murrell
ID: 21787957
can you post your dtasource
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 21790256
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Closing Comment

by:tnasca
ID: 31597258
Here is the final code:
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

public partial class Members_Reports_cr : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ReportDocument crReportDocument = new ReportDocument();
        crReportDocument.Load(@"C:\Sites\Tony\ST\ST_Web\Members\Reports\Entire.rpt");        
        Database crDatabase;
        Tables crTables;
        CrystalDecisions.CrystalReports.Engine.Table crTable;
        TableLogOnInfo crTableLogOnInfo;
        ConnectionInfo crConnectionInfo = new ConnectionInfo();
        crConnectionInfo.ServerName = "DNSERVER";
        crConnectionInfo.DatabaseName = "ST";
        crConnectionInfo.UserID = "xx";
        crConnectionInfo.Password = "yy";
        crDatabase = crReportDocument.Database;
        crTables = crDatabase.Tables;
        for (int i = 0; i < crTables.Count; i++)
            {
            crTable = crTables [i];
            crTableLogOnInfo = crTable.LogOnInfo;
            crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
            crTable.ApplyLogOnInfo(crTableLogOnInfo);
            //If your DatabaseName is changing at runtime, specify
            //the table location. For example, when you are reporting
            //off of a Northwind database on SQL server
            //you should have the following line of code:
            crTable.Location = "" +
                crTable.Location.Substring(crTable.Location.LastIndexOf
                (".") + 1);
            }        
       CrystalReportViewer1.ReportSource = crReportDocument;
    }
}
0
 

Expert Comment

by:DeonM
ID: 22109691
Im using VS 2008 Pro with its bundled CR tool and i am sitting with the same problem. I tried the solution and 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

Any help would be greatly appreciated.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 22112113
DeonM - Generally it is a good idea to ask your own question.  Only the asker and a limited number of experts will see this question.

mlmcc
0
 

Expert Comment

by:DeonM
ID: 22118119
I understand that, however I do have my own question but its not being addressed to. Been waiting for days for any replies :/
So i don't know what to do anymore.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now