Print Page | Close Window

Datasource Location For crystel report

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=13969
Printed Date: 03 May 2025 at 12:33pm


Topic: Datasource Location For crystel report
Posted By: ManKhl
Subject: Datasource Location For crystel report
Date Posted: 03 Aug 2011 at 11:26pm
I'v developed an application.which works very fine on my pc. I havent done any hardcode there. I Have following code on my crystel reportviewer



private void crystalReportViewer1_Load(object sender, EventArgs e)
        {
             HMSCon=new HMSConnection();
             connectionString = HMSCon.cn.ConnectionString;
             builder = new SqlConnectionStringBuilder(connectionString);
             password = builder.Password;
             username = builder.UserID;
             dataSource = builder.DataSource;
             initialCatalog = builder.InitialCatalog;

             myTBInfo = new TableLogOnInfo();
             myTBInfos = new TableLogOnInfos();
             myConn = new ConnectionInfo();
             myConn.ServerName = dataSource;
             myConn.DatabaseName = initialCatalog;
             myConn.Password = password;
             myConn.UserID = username;
             myTBInfo.ConnectionInfo = myConn;
             myTBInfos.Add(myTBInfo);
             crystalReportViewer1.LogOnInfo = myTBInfos;

try
             {
                 report = new FinalBillLodgingAndServices();
                 Lodgingreport = new FinalLodgingReportBill();
                 Servicereport = new FinalServiceBill();

                 String[] arrlis = (String[])RoomList.ToArray(typeof(string));
                 String[] servarrlis = (String[])ServiceroomsList.ToArray(typeof(string));
                 report.SetParameterValue("BookingId", bkinid);
                 report.SetParameterValue("RoomNames", arrlis);
                 report.SetParameterValue("BillStatus", "Paid");
                 report.SetParameterValue("LodgingPaybale", LodgingPayble);
                 report.SetParameterValue("AmountInWord", NetAmountINword);
                 report.SetParameterValue("PaybleServiceAmount", ServiceAmount,"FinalBillRoomServiceSubreport");
                 report.SetParameterValue("Rooms", servarrlis, "FinalBillRoomServiceSubreport");
              
                 crystalReportViewer1.ReportSource = report;
                 crystalReportViewer1.Refresh();

             }
             catch(Exception ex)
             {
                 MessageBox.Show(""+ex);
             }

}

but when i try to run that application on other pc it needs to set datasource location. and i need to rplace sql server name every time ..is der any way to open crystel report without seting this.



-------------
Develope the unique



Print Page | Close Window