473,385 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to prevent a DataBase logon message to pop up

Hi All

I am using a crystal report .net 2.0,
For designing the report i connected the report to a local data set whenfor the actually data suorce of the report i used the function:

CrystalReport.SetDataSource(data table);

When i run the application the report shows beautifully ,but if i try to disply the report by a installed application a DataBase Logon message pops up and demand a login id and password,

how cen i solve this prablem???

Thanks.

Chaya
Aug 7 '08 #1
1 992
Dear try to understand this and if you got any problem let me know


Expand|Select|Wrap|Line Numbers
  1. public partial class rptViewer : System.Web.UI.Page
  2. {
  3.     static ReportDocument rd = new ReportDocument();
  4.     ConnectionInfo ci = new ConnectionInfo();
  5.     protected void Page_Load(object sender, EventArgs e)
  6.     {
  7.         if (Request.QueryString["rpt"] != null)
  8.         {
  9.  
  10.             ci.ServerName = ConfigurationManager.AppSettings.Get("DBServer");
  11.             ci.DatabaseName = ConfigurationManager.AppSettings.Get("DBName");
  12.             //ci.IntegratedSecurity = true;
  13.             ci.UserID = ConfigurationManager.AppSettings.Get("DBLogin");
  14.             ci.Password = ConfigurationManager.AppSettings.Get("DBPass");
  15.             LoadRpt();
  16.         }
  17.     }
  18.  
  19.     protected void LoadRpt()
  20.     {
  21.         rd.Load(Server.MapPath("rpt/" + Request.QueryString["rpt"] + ".rpt"));
  22.         if (ApplyLogon(rd, ci))
  23.         {
  24.             for (int i = 1; i < Request.QueryString.Count; i++)
  25.             {
  26.                 rd.SetParameterValue(Request.QueryString.GetKey(i), Request.QueryString[i]);
  27.             }
  28.             Crv.ReportSource = rd;
  29.             Crv.Width = new Unit("100%");
  30.         }
  31.         else
  32.             lbltxt.Text = "Login info failed. Check DB settings";
  33.     }
  34.  
  35.     protected bool ApplyLogon(ReportDocument cr, ConnectionInfo ci)
  36.     {
  37.         TableLogOnInfo li;
  38.  
  39.         // for each table apply connection info
  40.         foreach (CrystalDecisions.CrystalReports.Engine.Table tbl in cr.Database.Tables)
  41.         {
  42.             li = tbl.LogOnInfo;
  43.             li.ConnectionInfo = ci;
  44.             tbl.ApplyLogOnInfo(li);
  45.  
  46.             // check if logon was successful
  47.             // if TestConnectivity returns false, check
  48.             // logon credentials
  49.             if (tbl.TestConnectivity())
  50.             {
  51.                 // drop fully qualified table location
  52.                 if (tbl.Location.IndexOf(".") > 0)
  53.                 {
  54.                     tbl.Location = tbl.Location.Substring(tbl.Location.LastIndexOf(".") + 1);
  55.                 }
  56.                 else tbl.Location = tbl.Location;
  57.             }
  58.             else return (false);
  59.         }
  60.         return (true);
  61.     }
  62.  
  63.     // The Logon method iterates through all tables
  64.     protected bool Logon(ReportDocument cr, string server, string db, string id, string pass)
  65.     {
  66.         ConnectionInfo ci = new ConnectionInfo();
  67.         SubreportObject subObj;
  68.         ci.ServerName = server;
  69.         ci.DatabaseName = db;
  70.         ci.UserID = id;
  71.         ci.Password = pass;
  72.  
  73.         if (!ApplyLogon(cr, ci)) return (false);
  74.  
  75.         foreach (ReportObject obj in cr.ReportDefinition.ReportObjects)
  76.         {
  77.             if (obj.Kind == ReportObjectKind.SubreportObject)
  78.             {
  79.                 subObj = (SubreportObject)obj;
  80.                 if (!ApplyLogon(cr.OpenSubreport(subObj.SubreportName), ci)) return (false);
  81.             }
  82.         }
  83.         return (true);
  84.     }
  85. }
Aug 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jamie Burns | last post by:
I have written a Windows Service to access an Oracle database. A dialog box appears, prompting for user logon if the database is not accessable due to network problems I just want the connection...
22
by: alecjames1 | last post by:
I have a form which the user must complete before closing. I have disabled the window x button and use my own exit button. When selected it checks to see if the user has completed the entries...
3
by: Michael S | last post by:
only my server get the report whitout the dialogue database login. I think it is where the database is localhost and the crystal report know not the connection string. how I can crystal reports...
3
by: Maellic | last post by:
Hi, The website I am working on is built with ASP.NET and connects to a SQL Server 2000 database. The web server and database are on the same machine. I have recently tried to modify the timeout...
1
by: John Dalberg | last post by:
Running Crystal Reports with the hotfixes and patches & VS 2003. I created a CR report on my development server which has SQL Server. The report runs fine inside Visual Studio. When I switched...
4
by: Shawn H. Mesiatowsky | last post by:
I have a strange problem here. I have my development computer with IIS installed, and we have a SQL server as well on a windows 2000 server. both are members of a domain. I have restricted access...
16
by: MLH | last post by:
If I give someone a runtime app, they can open the database window by pressing the F-11 key. How to prevent???
1
by: Luke Bailey | last post by:
I have an access database that I have secured using ueser-level security. I have my own logon in the Admins group. I have also removed Admin from the Admins group so that the standard end-user...
1
by: Jesse Aufiero | last post by:
What is the most sure-fire way to prevent users of my web site from sharing their logon information with others? i want to guarantee that only paying customers are allowed into the site. Thanks
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.