locked
crystal report asking for password everytime RRS feed

  • Question

  • User-1474096950 posted

    in my vb.net windows application i have crystal reports implemented

    for making it work properly after deploying on client side  i have

    the below code

     

     

     

     

     

     

     

     

     

     

     

     

    Dim cryRpt As New

    ReportDocument

     

    Dim crtableLogoninfos As New

    TableLogOnInfos

     

    Dim crtableLogoninfo As New

    TableLogOnInfo

     

    Dim crConnectionInfo As New

    ConnectionInfo

     

    Dim CrTables As

    Tables

     

    Dim CrTable As

    Table

     

    With

    crConnectionInfo

    .ServerName = ConfigurationManager.AppSettings(

    "ServerName")

    'YOUR SERVER NAME"

    .DatabaseName = ConfigurationManager.AppSettings(

    "MainData")

    'YOUR DATABASE NAME"

    .UserID = ConfigurationManager.AppSettings(

    "User_ID")

    'YOUR DATABASE USERNAME"

    .Password = ConfigurationManager.AppSettings(

    "Password")

    'YOUR DATABASE PASSWORD"..............................................

    End  With

    but when ever i tried to open the report or even in design mode click verify database it ask me for the password

    once the passwrod is assigned the report is dispalyed propely

    buti dont want to ask it for the password everytie i need to view or open the report

     

    Wednesday, February 16, 2011 4:53 AM

All replies

  • User-1808629394 posted

    Did you not forgot to apply the logon information?

    in your case something like:

     

    cryRpt.Database.Tables[0].ApplyLogOnInfo(crtableLogoninfo)

    Wednesday, February 16, 2011 5:59 AM
  • User-1011137159 posted

    Please use below code that with this you can able to resolve your problem.

     

    string DatabaseServer = ConfigurationManager.AppSettings["Server"];
                string userId = ConfigurationManager.AppSettings["Userid"];
                string Password = ConfigurationManager.AppSettings["Password"];
                string DataBaseName = ConfigurationManager.AppSettings["DataBase"];
    
                ReportDocument crReportDocument = new ReportDocument();
                crReportDocument.Load(AppDomain.CurrentDomain.BaseDirectory + "/Reports/rpData.rpt");
                //crReportDocument.SetDataSource(Ds);
                ConnectionInfo crConnectionInfo = new ConnectionInfo();
                TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
                TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
                //ConfigurationLocation objConnectionLocation = new ConfigurationLocation();
    
                crConnectionInfo.ServerName = DatabaseServer;
                crConnectionInfo.DatabaseName = DataBaseName;
                crConnectionInfo.UserID = userId;
                crConnectionInfo.Password = Password;
                crConnectionInfo.IntegratedSecurity = false;
                crConnectionInfo.Type = ConnectionInfoType.SQL;
                //crConnectionInfo.Attributes.Collection.Add(DbConnectionAttributes.CONNINFO_DATABASE_DLL, DbConnectionAttributes.DATABASE_DLL_CRDB_ODBC);
                Tables CrTables;
    
                CrTables = crReportDocument.Database.Tables;
                foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                {
                    crtableLogoninfo = CrTable.LogOnInfo;
                    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                    //CrTable.Location = DataBaseName + ".dbo." + CrTable.Name;
                    CrTable.ApplyLogOnInfo(crtableLogoninfo);
                }
    Wednesday, February 16, 2011 6:08 AM
  • User-1474096950 posted

    thisis the code that i have

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

    CrystalReportViewer1.Load

     

    Dim cryRpt As New

    ReportDocument

     

    Dim crtableLogoninfos As New

    TableLogOnInfos

     

    Dim crtableLogoninfo As New

    TableLogOnInfo

     

    Dim crConnectionInfo As New

    ConnectionInfo

     

    Dim CrTables As

    Tables

     

    Dim CrTable As

    Table

     

    With

    crConnectionInfo

    .ServerName = ConfigurationManager.AppSettings(

    "ServerName")

    'YOUR SERVER NAME"

    .DatabaseName = ConfigurationManager.AppSettings(

    "MainData")

    'YOUR DATABASE NAME"

    .UserID = ConfigurationManager.AppSettings(

    "User_ID")

    'YOUR DATABASE USERNAME"

    .Password = ConfigurationManager.AppSettings(

    "Password")

    'YOUR DATABASE PASSWORD"

     

    End

    With

     

     

    Dim ReportName As String =

    "cons.rpt"

     

    ' Dim ReportName As String = "individual_bill.rpt"

    ReportName = Application.StartupPath &

    "\" & ReportName &

    ""

     

    Dim ReportForm As CrystalDecisions.CrystalReports.Engine.ReportDocument = New

    CrystalDecisions.CrystalReports.Engine.ReportDocument

    ReportForm.Load(ReportName)

     

     

    CrTables = ReportForm.Database.Tables

     

    For Each CrTable In

    CrTables

    crtableLogoninfo = CrTable.LogOnInfo

    crtableLogoninfo.ConnectionInfo = crConnectionInfo

    CrTable.ApplyLogOnInfo(crtableLogoninfo)

     

    Next

    CrystalReportViewer1.ReportSource = ReportForm

    CrystalReportViewer1.Refresh()

     

    End

    Sub

    Wednesday, February 16, 2011 6:35 AM
  • User-1011137159 posted

    After looks to you code I found that there are no data binding in availale in code so I think that you have added at desing tome.

    So remove that from desing time and add that part from run time with below code.

                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString);
                SqlCommand cmd = new SqlCommand("exec MyData", conn);
                cmd.CommandType = CommandType.Text;
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet Ds = new DataSet();
                da.Fill(Ds);
    
                crReportDocument.SetDataSource(Ds.Tables[0]);
                CrystalReportViewer1.ReportSource = crReportDocument;
                CrystalReportViewer1.ToolbarStyle.CssClass.Equals("CrystalReportToolbar");
                CrystalReportViewer1.DataBind();
                CrystalReportViewer1.RefreshReport();

     

    Please mark as answer if this is helos

    Wednesday, February 16, 2011 6:44 AM
  • User-1474096950 posted

    culd u plz explain in detail
    i am doing this for first time
    my sceanrio is in this way

    i have a total of 6 reports of which 5 are generated with data directly from the tables
    so this 5 reports links i have given to the main mdi form
    on which i have as
    dim firstreport as new frmone
    firstreport.mdiparent=me
    firstreport.show()

    1)i have taken a form with crystal reportviewer in it
    2) designed the crystal report seperately from the drag drop of fields frm the table at design time (one.rpt)
    3) set the reportsource of crystalviewer to one.rpt
    4) in the code window of the form conatining crystalviewer i have added the above code


    for the 6th report which is genereated based on the record selection of the form  i have taken dataset & populated it with the record as "select * from table1 where name= '" & drpdwnname.selectedvalue.text & "'"

    & on this form on a button click i need to dislay the report

    how do i design at run time?

    and one mor ethig i have put all the reports in a folder REPORTS

    but it was not accepting . so i have copied all that reports in BIN folder

    so the report is taken frm bin folder. is there any way that it taken from report folder only

    Wednesday, February 16, 2011 7:09 AM
  • User-1474096950 posted

    culd i get any help for crystal report issue

    Thursday, February 17, 2011 4:35 AM
  • User-660870441 posted

    Hi,<o:p></o:p>

    For Crystal Reports related questions, I think the following forums will be more helpful for you:<o:p></o:p>

    Crystal Reports (in ASP.NET)<o:p></o:p>

    Crystal Reports for Visual Studio (in MSDN)<o:p></o:p>

    Hope this helps.<o:p></o:p>

    Wednesday, February 23, 2011 2:18 AM