Set connection string in ASP .net (2002) for CR 8.5

Dear all,

does anyone of you know how to set connection string in ASP .net 2002 for CR 8.5?

Thanks
ultrafishAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ultrafishAuthor Commented:
The situation is I am using asp .net VS 2002 and CR 8.5, in the report, I use file dsn to connect to the database which works properly when I simply view the report, but when I go to .NET, I cannot set the logon info properly, the following is my code, does anyone has anyidea?

ReportDocument rptDoc = new ReportDocument();
rptDoc.Load("C:\\report.rpt");
rptDoc.SetParameterValue("param1", "1");
rptDoc.SetParameterValue("param2", "2");
rptDoc.SetDatabaseLogon("username", "password", "server", "database");                  
crViewer.ReportSource = rptDoc;
rptDoc.Export();

I simply connect to the database....
thanks
0
ebolekCommented:
Use this code
Call SetConnection(rptdoc). It will solve your problems

internal static void SetConnection(ref ReportDocument report)
            {
                  try
                  {
                        CrystalDecisions.Shared.TableLogOnInfo MyLogonInfo;
                        foreach(CrystalDecisions.CrystalReports.Engine.Table MyTable in report.Database.Tables)
                        {    
                              MyLogonInfo = MyTable.LogOnInfo;
                              MyLogonInfo.ConnectionInfo.ServerName  = ServerName;
                              MyLogonInfo.ConnectionInfo.DatabaseName = DatabaseName;
                              MyLogonInfo.ConnectionInfo.UserID  = UserName;
                              MyLogonInfo.ConnectionInfo.Password = Password;                              
                              MyTable.Location = MyTable.Location.Substring(MyTable.Location.LastIndexOf(".")+1);
                              MyTable.ApplyLogOnInfo(MyLogonInfo);            
                        }                        
                  }
                  catch( Exception logonInfoException )
                  {
                        throw logonInfoException;
                  }
            }
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ebolekCommented:
Glad to help

Regards
Emre
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.