locked
Crystal Reports asks for Username and Password while loading - ASP.NET 2.0 RRS feed

  • Question

  • User504602950 posted

    Dear All,


    I have designed my first Crystal Report using ASP.NET 2.0, C# and Sql server 2005 EE. It is displaying the report details correctly. But it’s asking the following details every time I try to access the reports…

    Server name:
    Database name:
    User name:
    <!--[if !supportEmptyParas]-->Password: <!--[endif]--><o:p></o:p>



    Please let me know How to automatically pass the above information to reports.


    Regards,
    Jagadeesh

    Monday, July 9, 2007 1:28 AM

Answers

  • User504602950 posted

     Hey I got the Solution in this form, Thanks Lawrence.

    Here is the code for that in VB.NET:

    ############################## 

    On the page load or button click or whatever you want to run the report on you need to add the following: configureCRYSTALREPORT()

    Private Sub configureCRYSTALREPORT()
    Dim myConnectionInfo As New ConnectionInfo()

    myConnectionInfo.DatabaseName = "DatabserName"
    myConnectionInfo.UserID = "UID"
    myConnectionInfo.Password = "PWD"
    setDBLOGONforREPORT(myConnectionInfo)
    End Sub

    Private Sub
    setDBLOGONforREPORT(ByVal myconnectioninfo As ConnectionInfo)
    Dim mytableloginfos As New TableLogOnInfos()
    mytableloginfos = CrystalReportViewer1.LogOnInfo
    For Each myTableLogOnInfo As TableLogOnInfo In mytableloginfos
    myTableLogOnInfo.ConnectionInfo = myconnectioninfo
    Next

    End Sub

     -------------------------------------------------------------------------------------------------------------------------------------------------

     

    Here is the code for that in C#:

    ##########################

     
        private void setDBLOGONforREPORT(ConnectionInfo myconnectioninfo)
        {
            TableLogOnInfos mytableloginfos = new TableLogOnInfos();
            mytableloginfos = CrystalReportViewer1.LogOnInfo;
            foreach (TableLogOnInfo myTableLogOnInfo in mytableloginfos)
            {
                myTableLogOnInfo.ConnectionInfo = myconnectioninfo;
            }

        }

    In Page Load....
            ConnectionInfo myConnectionInfo = new ConnectionInfo();

            myConnectionInfo.ServerName = "serverName";
            myConnectionInfo.DatabaseName = "DatabaseName";
            myConnectionInfo.UserID = "sa";
            myConnectionInfo.Password = "pwd";
            setDBLOGONforREPORT(myConnectionInfo);

     -------------------------------------------------------------------------------------------------------------------------------------------------

     Thanks!!

    Jagadeesh

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 11, 2007 6:29 AM

All replies

  • User-1556678718 posted

    you have to fill the tables in the datasets you aer ysing in the page where you have the report viewer lets say in Page_Load, like this:

    SomeDataSetTableAdapters.SomeDataSetTableAdapter listTable = new SomeDataSetTableAdapters.SomeDataSetTableAdapter();SomeDataSet ds= new SomeDataSet();

    listTable.Fill(ds.theTable, parameter1,...);

    CrystalReportSource1.ReportDocument.Database.Tables["SomeDataSet"].SetDataSource(lPropozer);

    CrystalReportSource1.DataBind();

    CrystalReportViewer1.DataBind();

     

     

    Monday, July 9, 2007 5:24 AM
  • User504602950 posted

     Hey I got the Solution in this form, Thanks Lawrence.

    Here is the code for that in VB.NET:

    ############################## 

    On the page load or button click or whatever you want to run the report on you need to add the following: configureCRYSTALREPORT()

    Private Sub configureCRYSTALREPORT()
    Dim myConnectionInfo As New ConnectionInfo()

    myConnectionInfo.DatabaseName = "DatabserName"
    myConnectionInfo.UserID = "UID"
    myConnectionInfo.Password = "PWD"
    setDBLOGONforREPORT(myConnectionInfo)
    End Sub

    Private Sub
    setDBLOGONforREPORT(ByVal myconnectioninfo As ConnectionInfo)
    Dim mytableloginfos As New TableLogOnInfos()
    mytableloginfos = CrystalReportViewer1.LogOnInfo
    For Each myTableLogOnInfo As TableLogOnInfo In mytableloginfos
    myTableLogOnInfo.ConnectionInfo = myconnectioninfo
    Next

    End Sub

     -------------------------------------------------------------------------------------------------------------------------------------------------

     

    Here is the code for that in C#:

    ##########################

     
        private void setDBLOGONforREPORT(ConnectionInfo myconnectioninfo)
        {
            TableLogOnInfos mytableloginfos = new TableLogOnInfos();
            mytableloginfos = CrystalReportViewer1.LogOnInfo;
            foreach (TableLogOnInfo myTableLogOnInfo in mytableloginfos)
            {
                myTableLogOnInfo.ConnectionInfo = myconnectioninfo;
            }

        }

    In Page Load....
            ConnectionInfo myConnectionInfo = new ConnectionInfo();

            myConnectionInfo.ServerName = "serverName";
            myConnectionInfo.DatabaseName = "DatabaseName";
            myConnectionInfo.UserID = "sa";
            myConnectionInfo.Password = "pwd";
            setDBLOGONforREPORT(myConnectionInfo);

     -------------------------------------------------------------------------------------------------------------------------------------------------

     Thanks!!

    Jagadeesh

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 11, 2007 6:29 AM
  • User-2050545975 posted

     Hi Jagadeesh

    Even i'm also facing the same problem

    when i run the application its asking username, pwd ,database .

    i tried ur code but its giving error that "ConnectionInfo " is not defined

    should i include any namespace? 

    how to solve this

    thanks in advance

    Archu 

     

    Wednesday, September 26, 2007 5:23 AM
  • User624952157 posted

    hai jagadeesh

    i have face same problem as u face

    database name

    user name

    password

    i can't understand how to slove this problem if u have any soluation or demo with solve this problem then plz send me

    on my mail

    saroop.trivedi@gmail.com

    i hope you reply me

    Saturday, May 17, 2008 5:39 PM
  • User-1130287460 posted

    Archu....

    Imports CrystalDecisions.Shared

    Imports CrystalDecisions.CrystalReports.Engine

     

    Sunday, May 18, 2008 1:07 AM
  • User-1569651472 posted

    hi

    thanks for the reply.i need some more clarification.

    server is name of the server.

    database is database name.

    but what should i give for username and password?????

     

    Monday, May 19, 2008 4:44 AM
  • User-1130287460 posted

    heres one exmple

        Private Sub configureCrystalReports()
            Dim myconnectioninfo As ConnectionInfo = New ConnectionInfo()
            myconnectioninfo.DatabaseName = ".\SQLEXPRESS"
            myconnectioninfo.UserID = "sa"
            myconnectioninfo.Password = "sqlPassword"
            SetDBLogOnForReport(myconnectioninfo)

        End Sub

        Private Sub SetDBLogOnForReport(ByVal myConnectionInfo As ConnectionInfo)
            Dim myTableLogonInfos As TableLogOnInfos = CrystalReportViewer1.LogOnInfo
            For Each myTabeLogoninfo As TableLogOnInfo In myTableLogonInfos
                myTabeLogoninfo.ConnectionInfo = myconnectioninfo
            Next
        End Sub

     

    --------------------------------------------------------------------------------------------------------------------

     Don't worry no one is going to see this, you can use the same uername and password for login on to your sqlserver, no need to change this while you deploying,, the server will automaticall detect this from config...

    Monday, May 19, 2008 5:06 AM
  • User-1646638908 posted

     

    The code above posted is similar if not verbatim from the code walkthroughs I am working with RIGHT NOW (5:30 AM) this morning I have been on this since 1:00 AM.

    I asked the same question in this thread: http://forums.asp.net/t/1262984.aspx  but I thought I would piggyback my question here since this is exactly the context of what I am doing.

    In any case when I Add the following line to the  Sub ConfigureCrystalReports() I expect as documented that it will now respect the servername for connection information. But it does not...  Wondering if someone could simply try it and report results.  What I get is prompting for connection information wherin the Database Server is uneditable and is the original from where I defined the report.

    myConnectionInfo.ServerName = "yadda"

     

    Thanks in advance

    Monday, May 19, 2008 5:36 AM
  • User703214998 posted

    I've seen many flavors of the code posted above, but when I call my report I still get a window which says

     "The report you requested requires further information" and prompts me for Server Name, Database name, user name (which are all filled in) and password, which is not filled in.

     Could it be some configuration on the server causing this.

     I developed the report using Crystal built into VS2008 and this is an asp.net app.

    Thursday, October 23, 2008 11:44 AM
  • User-2083267098 posted

    I had the same problem, the report was working on my development machine but on the server it keeps asking for the logon info, even with the code mentioned above.

    I found out that the server was missing the native SQL client which is used in the report, I fixed it by downloading the native SQL client installer from MS and installing it on the server.

    This page contains the links and this is the direct download for the x86 version of the client

    Friday, October 24, 2008 11:09 AM
  • User1083688297 posted

     

    but what should i give for username and password?????

    Finally, something I know a little bit about!

    You will want to set up a Usercode and Password in SQLServer that has read rights to the database that you are accessing.  Lack of Permissions can give you the same problems as invalid/missing Usercode/Passwords.  Another thing the think about is whether you have subreports.  Again, you need to set the Usercode/Password up.  I don't remember the exact code, but a search should find it.

    Saturday, October 25, 2008 4:56 PM
  • User624952157 posted

     Hello u do one thing

    also write the in web.config file of ur application 

    add the user id and password in connection string of ur database

     

    by default apply the

     

    User Id=sa

    and 

    password=pass2word

    if u not got the soluation the i reply me because i sloved this problem

     

     

    Friday, November 7, 2008 1:23 AM
  • User553514529 posted

     

    Hi even i agetting the same question

    i dont even the server name username password please help me how to find it

    it would be grate full if i et the answer soon

    Saturday, January 24, 2009 7:28 AM
  • User553514529 posted

    Hi still i am not getting it please help me out

    Saturday, January 24, 2009 7:30 AM
  • User-1410524394 posted

     Hi,

     

    I implemented this. There are no errors but it is still asking for the database credentials. What to do now? 

     

    Thanks

    Wednesday, January 28, 2009 11:39 AM
  • User-2083267098 posted

    Did you make sure the computer has the sql native drivers (or whatever drivers needed for the connection type you have) installed?

     

    that was the cause of this behaviour in my case

    Wednesday, January 28, 2009 12:18 PM
  • User624952157 posted

    WEB.CONFIG SETTING

    ----------------------------

    <add name="CONNECTIONSTRING" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\XXX.mdf;Integrated Security=True;User Instance=True;User ID=sa;Password=pass@word1;" providerName="System.Data.SqlClient"/>

    aspx.CS CODING

    -------------------

     public void reportconnection()
    {

    string sql = string.Empty;

    sql = "select * from TABLE1";// order by seat_no";


    ConnectionInfo ConnInfo = new ConnectionInfo();
    ConnInfo.DatabaseName = "UNI.MDF";
    ConnInfo.UserID = "sa";
    ConnInfo.Password = "pass@word1";

    ConnInfo.IntegratedSecurity = true;

    SqlDataAdapter da = new SqlDataAdapter();
    da = new SqlDataAdapter(sql, conn);
    da.Fill(ds, tablename);


    dc.Load(Server.MapPath("~//REPORTNAME.rpt"));

    ds.Tables[0].TableName = "report1";

    // XML WRITE AND READ THE FILE FOR CRYSTAL REPORT DATA SOURCE
    ds.WriteXml(AppDomain.CurrentDomain.BaseDirectory + "//med.xml", XmlWriteMode.WriteSchema);
    ds = null;
    ds = new DataSet();
    ds.ReadXml(AppDomain.CurrentDomain.BaseDirectory + "/med.xml");





    dc.SetDataSource(ds);

    CrystalReportViewer1.ReportSource = dc;
    CrystalReportViewer1.DataBind();
    CrystalReportViewer1.RefreshReport();
    conn.Close();



    }
    
    
    Call above function at page_init() method 
    
    
    if any query please freely contact with me

    Monday, June 20, 2011 2:35 AM
  • User-1582039473 posted

    i apply u r code like this way.

    but still its show the same error..

    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.OleDb;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    using System.Data.SqlClient;

    public partial class esic_month_regi : System.Web.UI.Page
    {
        SqlConnection con;
        protected void Page_Load(object sender, EventArgs e)
        {

            ConnectionInfo ConnInfo = new ConnectionInfo();
            ConnInfo.DatabaseName = "HDFC";
            ConnInfo.UserID = "sa";
            ConnInfo.Password = "sa@123";

            ConnInfo.IntegratedSecurity = true;
        }

         


        protected void btnok_Click(object sender, EventArgs e)
        {
            DataSet2 dsReport = new DataSet2();

            // Create SQL Connection And Command And Fill DataSet1
            con = new SqlConnection("Data Source= MAIN_SERVER\\SQLEXPRESS ;Initial Catalog=HDFC;Integrated Security=True");

            con.Open();
            string strSelect = "SELECT TKTNO FROM PAYMST";

            ConnectionInfo ConnInfo = new ConnectionInfo();
            ConnInfo.DatabaseName = "HDFC";
            ConnInfo.UserID = "sa";
            ConnInfo.Password = "sa@123";

            ConnInfo.IntegratedSecurity = true;


            SqlCommand cmd = new SqlCommand(strSelect, con);
            SqlDataAdapter dAdapter = new SqlDataAdapter(cmd);

            dAdapter.Fill(dsReport.Tables["reportTable"]);
            con.Close();

            //Set Report Source
            ReportDocument crystalReport = new ReportDocument();

            crystalReport.Load(Server.MapPath("Report\\CrystalReport.rpt"));
            crystalReport.SetDataSource(dsReport);
            CrystalReportViewer1.ReportSource = crystalReport;

            CrystalReportViewer1.DataBind();
            CrystalReportViewer1.RefreshReport();
            
        }
    }

    Friday, July 6, 2012 3:22 AM