Crystal Reports DataBase Fields

Hi,
I'd like to know if is possible to set the query string and the DataBase when you want to open a Crystal Report from SBO.
Thanks.

You cannot set the database connection string from the SBO connection information because the password is encrypted.
But if can grab the password from somewhere else you can do it like this:
    private void SetConnectionInfo(CrystalDecisions.Shared.ConnectionInfo crConnectionInfo, ReportClass report)
      TableLogOnInfo crTableLogOnInfo;
      report.SetDatabaseLogon(conn.UserId, conn.Password, conn.Server, conn.Database);
      crConnectionInfo.ServerName = conn.Server;
      crConnectionInfo.DatabaseName = conn.Database;
      crConnectionInfo.UserID = conn.UserId;
      crConnectionInfo.Password = conn.Password;
      foreach(Table table in report.Database.Tables)
        crTableLogOnInfo = table.LogOnInfo;
        crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
        table.ApplyLogOnInfo(crTableLogOnInfo);
        string s = table.Location;
        s = crConnectionInfo.DatabaseName + "." /*dbo." */ + table.Location.Substring(table.Location.LastIndexOf(".") + 1) ;
        table.Location = crConnectionInfo.DatabaseName + "." /*dbo."*/ + table.Location.Substring(table.Location.LastIndexOf(".") + 1) ;
Hope this helps,
Jurgen

Similar Messages

  • Seagate Crystal Reports: Database Error

    I am using Crystal reports Version 8 and frequently get the error 'Seagate Crystal Reports: Database Error' when I try to open a previously working crystal report file. The error occurs when I click on the Database menu. Every time I get this error I end up redesigning the report as the I have not yet found a solution and I cant run the report.
    The error is a message box with the title 'Seagate Crystal Reports: Database Error' and an ok button - nothing else.
    Its very frustrating!
    Please help.
    Thanks.

    Hi,
    What database are you using and how are you connecting to it? 
    What are you clicking in the Database menu:  Set Location, Verify Database, Show SQL Query?
    Before opening the report, can you connect to the database first then open the report? 
    I would have expected an error code or a more descriptive error to follow. 
    Thanks,
    Brian

  • Crystal Report Formula field function  on OLAP SAP BI/BW Cube

    Dear All
    We create OLAP Cube Report in  Crystal Report 2008 (BO)  base  SAP ( DB2)  BI/BW  Cube, Grid report coming correctly.  Crystal Report Formula Field  functionalities are not avilabel or suporting.  If any one explain or some kind of documentation available pl.  help me.
    Thanks,   in advance.
    Alfred.M

    Hi,
    you are using the OLAP Grid which will only have limited functionality. You can use the BW MDX Driver and then connect to a BEx query and you will have the complete functionality in CR
    Ingo

  • Crystal reports "Database login failed" when using push method

    I have a web application (ASP.NET, .NET v3.5), that pushes data to a CR 2008 report. On two servers one of the three reports returns a "Database login failed" error. I am stumped since there is no login, it's push not pull; in addition the problem is hard to debug since it works fine from my developers workstation. I have "updated" the xsd in that report, reinstalled the app, etc., non of which helped. If anyone has a solution or even ideas I'd appreciate the help.

    What about following the troubleshooting steps as described in the blog;
    Create an XML file off of your dataset. Make sure this is done just before you set the dataset to the report:
                rpt.Load(rptPath)
    myDataset.WriteXml(xmlPath, XmlWriteMode.WriteSchema)
    rpt.SetDataSource(myDataset)
    Copy the above created XML to your development system
    Open the problem report in the Crystal Reports designer
    In the Desigger, go to the Database menu and select u201CSet Datasource Locationu201D
    In the u201CReplace with:u201D pane, expand the u201CCreate New Connectionu201D folder.
    Double click the u201CADO .NET (XML)u201D icon
    Browse to the location of the XML file you created in step (1)
    Click on the path to the XML. The <Update> button should enable
    Click on the <Update> button
    Typically, either of the following will happen:
    You will get a u201CMap Fieldsu201D dialog. This indicates that the XML written off of your dataset does not match what the report is expecting. This may be due to incorrect fields name, incorrect field type, etc. You will now need eliminate the difference.
    Incorrect data or no data. There is an issue with your dataset and you need to determine why the data is not present in your dataset. Looking at the XML may be a good place to start.
    Ludek

  • Crystal Report Database Query

    Hi I would like to ask regarding queries from the database. I have 2 main tables that gets their images from 1 master table.
    First is TASK table and Second is ASSET table. Both tables are relational.
    Each Task has Asset connected by Task_Asset_ID.
    But both tasks and each assets may have also images from the Image table thru Assignment table. But I am wondering how could I query the data to show tasks with images and assets with images in one row.
    For example
    Task 1 may have Green.jpg
    Asset 222 may have Red.jpg
    Knowing that Task and Asset are relational, is it possible to show them in one row in crystal report?
    Task
    TaskID
    TaskName
    Task_Asset_ID
    1
    Task1
    111
    2
    Task2
    222
    3
    Task3
    111
    Asset
    AssetID
    AssetName
    111
    Asset1
    222
    Asset2
    Images
    imgID
    ImgName
    1
    Red.jpg
    2
    Yellow.jpg
    3
    Blue.jpg
    4
    Green.jpg
    Assignment
    AssID
    TaskOrAssetID
    ImgID
    Type
    1
    1
    4
    X
    2
    222
    1
    Z
    3
    3
    3
    Z
    4
    111
    2
    X

    Ok, this is going to get a bit complicated, but this is possible.  The problem is that the Assignment table records can have either TaskID or AssetID, so you're going to have to use some tables twice with aliases.
    Here's what I'd do...
    In the Database Expert:
    1.  Add all of the tables to your report.
    2.  Add a second copy of Assignment and Images - when you do this, Crystal will warn you that the table is already in the report and ask if you want to "alias" it.  At that point it will add the table with "_1" at the end of the table name.  So, you'll have Assignment_1 and Images_1.
    3.  On the linking tab, create the following links:
         Task.Task_Asset_ID to Asset.AssetID
         Task.TaskID to Assignment.TaskOrAssetID - make this a left outer join (see below)
         Assignment.ImgID to Images.ImgID - make this a left outer join
         Asset.AssetID to Assignment_1.TaskOrAssetID - make this a left outer join
         Assignment-1.ImgID to Images_1.ImgID - make this a left outer join.
    To make a left outer join, right-click on the join and select "Join Options".  Select "Left Outer" and save the join.  Left outer joins will provide data even when there is no matching value in the table that you're linking to - the values from that table will be null.
    In your report:
    1.  Put the following column headers on the report:
         Task Name
         Task Image
         Asset Name
         Asset Image
    2. Put the following fields in the details of the report:
        {Task.TaskName}
        {Images.ImgName}
        {Asset.AssetName}
        {Images_1.ImgName}
    3. Sort the data by Task Name and Asset Name.
    -Dell

  • How to change crystal report data field at runtime ?

    Hello everyone,
    I have a Crystal Report file ,which i am using to generate report for my windows form project .
    In that report i have a filed called as Quantity which data type is set as decimal, the requirement is like that the number of value those comes after decimal point that should be set according to the value which is given by the user at the run time .
    For eg: If user gives 1 at the run time then the report Qty field value set one value after decimal point. Like 12.1
    if user gives 2 then Qty field the value is 12.22 like tat  but user can give from zero to any number.. and if it is zero it should not show decimal
    Note: The main idea hear is how to change the filed in Crystal Report decimal point value by using code(or we say writing code we need to set manually as user input it will change)
    Can any body help me how to solve this issue .
    S.K Nayak

    I think you could probably make the field you see a formula field and take a parameter as the number of decimal places.
    totext converts a number to a string.
    totext({decimalField}, 2)
    That's 2 decimal places.
    You could probably substitute a {parameter} for that 2.
    If not then you could substitute an entire formula.
    To explore formulas:
    foreach (FormulaFieldDefinition f in rpt.DataDefinition.FormulaFields)
    MessageBox.Show(f.Name);
    // f.Text = your new formula
    Where rpt is an instantiated report.
    Or add another string field which you display in the column and do the calculation with the original decimal.
    Hope that helps.
    Recent Technet articles:
    Property List Editing;  
    Dynamic XAML

  • Crystal report database logon failed through ODBC in report

    Please see viewpage.cs in type = "FPR"  in my web application
    https://sourceforge.net/projects/aspchequesprint/
    is it my program code problem ?
    i edited as following also not work, when i update with crystal report 2008 sp1 it said version is too low
                    TableLogOnInfo crTableLogonInfo = new TableLogOnInfo();
                    for (int i = 0; i < objRpt.Database.Tables.Count - 1; i++)
                        crTableLogonInfo.ConnectionInfo.ServerName = "Cheque";
                        crTableLogonInfo.ConnectionInfo.DatabaseName = database_name;
                        crTableLogonInfo.ConnectionInfo.UserID = "sa";
                        crTableLogonInfo.ConnectionInfo.Password = "fa920711";
                        objRpt.Database.Tables<i>.ApplyLogOnInfo(logOnInfo);
                    TableLogOnInfos crTableLogonInfos = new TableLogOnInfos();
                    crTableLogonInfos.Add(crTableLogonInfo);
                    CrystalReportViewer1.LogOnInfo = crTableLogonInfos;

    can not load database info after edit the code in above link
    i use p2sodbc.dll it said can not load database info,
    error at objRpt.ReportClientDocument.DatabaseController.SetTableLocation(boTables[0], boTable);
    is the code correct?
    public partial class _Default : System.Web.UI.Page
            private ReportDocument objRpt = null;
            protected void Page_Unload(object sender, EventArgs e)
                if (this.objRpt != null)
                    this.objRpt.Close();
                    this.objRpt.Dispose();
            protected void Page_Load(object sender, EventArgs e)
                CrystalReportViewer1.HasToggleGroupTreeButton = false;
                CrystalReportViewer1.HasToggleParameterPanelButton = false;
                CrystalReportViewer1.HasPrintButton = true;
                CrystalReportViewer1.HasDrilldownTabs = false;
                CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
                CrystalReportViewer1.PrintMode = CrystalDecisions.Web.PrintMode.ActiveX;
                string database_name = "Cheque_Test";
                string odbc_name = "Cheque";
                string db_username = "martinhylee";
                string db_password = "fa920711";
                objRpt = new ReportDocument();
                string reportPath = @"C:\michael\access_test\Cheque\Ada\Reports\Report1_85.rpt";
                objRpt.Load(reportPath, OpenReportMethod.OpenReportByTempCopy);
                //'Create a new Stored Procedure Table to replace the reports current table.
                CrystalDecisions.ReportAppServer.DataDefModel.Procedure boTable = new CrystalDecisions.ReportAppServer.DataDefModel.Procedure();
                //'boMainPropertyBag: These hold the attributes of the tables ConnectionInfo object
                PropertyBag boMainPropertyBag = new PropertyBag();
                //'boInnerPropertyBag: These hold the attributes for the QE_LogonProperties
                //'In the main property bag (boMainPropertyBag)
                PropertyBag boInnerPropertyBag = new PropertyBag();
                //'Set the attributes for the boInnerPropertyBag
                boInnerPropertyBag.Add("Connect Timeout", "15");
                //boInnerPropertyBag.Add("Data Source", "MyDataSource");
                boInnerPropertyBag.Add("Data Source", odbc_name);
                boInnerPropertyBag.Add("DataTypeCompatibility", "0");
                boInnerPropertyBag.Add("General Timeout", "0");
                //boInnerPropertyBag.Add("Initial Catalog", "MyCatalog");
                boInnerPropertyBag.Add("Initial Catalog", database_name);
                boInnerPropertyBag.Add("Integrated Security", "False");
                boInnerPropertyBag.Add("Locale Identifier", "1033");
                boInnerPropertyBag.Add("MARS Connection", "0");
                boInnerPropertyBag.Add("OLE DB Services", "-5");
                boInnerPropertyBag.Add("Provider", "SQLNCLI");
                boInnerPropertyBag.Add("Tag with column collation when possible", "0");
                boInnerPropertyBag.Add("Trust Server Certificate", "0");
                boInnerPropertyBag.Add("Use Encryption for Data", "0");
                //'Set the attributes for the boMainPropertyBag
                //boMainPropertyBag.Add("Database DLL", "crdb_ado.dll");
                boMainPropertyBag.Add("Database DLL", "p2sodbc.dll");
                boMainPropertyBag.Add("QE_DatabaseName", "VEPILOT");
                boMainPropertyBag.Add("QE_DatabaseType", "OLE DB (ADO)");
                //'Add the QE_LogonProperties we set in the boInnerPropertyBag Object
                boMainPropertyBag.Add("QE_LogonProperties", boInnerPropertyBag);
                boMainPropertyBag.Add("QE_ServerDescription", "MyServer");
                boMainPropertyBag.Add("QE_SQLDB", "True");
                boMainPropertyBag.Add("SSO Enabled", "False");
    Edited by: Don Williams on Jul 12, 2011 8:47 AM

  • How to Change Crystal Report database name from visual basic code?

    Hi all,
    I have created a Crystal Report (CR)  with .NET VB. I also have developd some UDTs for that pusrpose and everything is OK.
    However I cannot use the same CR in another Company which has the same UDTs. I have not found how Connect to Company (in other words change the DB the report reads).
    Any Idea?
    Thanks,
    Vangelis
    Edited by: Vangelis Kanellopoulos on Jul 19, 2008 6:07 PM
    Edited by: Vangelis Kanellopoulos on Jul 20, 2008 10:27 AM
    Edited by: Vangelis Kanellopoulos on Jul 20, 2008 10:28 AM

    Hi Vangelis,
    Here's a simple VB class that has functions for setting the login details for the report and passing parameters.
    Option Strict Off
    Option Explicit On
    Public Class CrystalFunctions
        Enum ParamType As Integer
            Int
            Text
        End Enum
        Public Shared Sub SetCrystalLogin(ByVal sUser As String, ByVal sPassword As String, ByVal sServer As String, ByVal sCompanyDB As String, _
               ByRef oRpt As CrystalDecisions.CrystalReports.Engine.ReportDocument)
            Dim oDB As CrystalDecisions.CrystalReports.Engine.Database = oRpt.Database
            Dim oTables As CrystalDecisions.CrystalReports.Engine.Tables = oDB.Tables
            Dim oLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
            Dim oConnectInfo As CrystalDecisions.Shared.ConnectionInfo = New CrystalDecisions.Shared.ConnectionInfo()
            oConnectInfo.DatabaseName = sCompanyDB
            oConnectInfo.ServerName = sServer
            oConnectInfo.UserID = sUser
            oConnectInfo.Password = sPassword
            ' Set the logon credentials for all tables
            For Each oTable As CrystalDecisions.CrystalReports.Engine.Table In oTables
                oLogonInfo = oTable.LogOnInfo
                oLogonInfo.ConnectionInfo = oConnectInfo
                oTable.ApplyLogOnInfo(oLogonInfo)
            Next
            ' Check for subreports
            Dim oSections As CrystalDecisions.CrystalReports.Engine.Sections
            Dim oSection As CrystalDecisions.CrystalReports.Engine.Section
            Dim oRptObjs As CrystalDecisions.CrystalReports.Engine.ReportObjects
            Dim oRptObj As CrystalDecisions.CrystalReports.Engine.ReportObject
            Dim oSubRptObj As CrystalDecisions.CrystalReports.Engine.SubreportObject
            Dim oSubRpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            oSections = oRpt.ReportDefinition.Sections
            For Each oSection In oSections
                oRptObjs = oSection.ReportObjects
                For Each oRptObj In oRptObjs
                    If oRptObj.Kind = CrystalDecisions.Shared.ReportObjectKind.SubreportObject Then
                        ' This is a subreport so set the logon credentials for this report's tables
                        oSubRptObj = CType(oRptObj, CrystalDecisions.CrystalReports.Engine.SubreportObject)
                        ' Open the subreport
                        oSubRpt = oSubRptObj.OpenSubreport(oSubRptObj.SubreportName)
                        oDB = oSubRpt.Database
                        oTables = oDB.Tables
                        For Each oTable As CrystalDecisions.CrystalReports.Engine.Table In oTables
                            oLogonInfo = oTable.LogOnInfo
                            oLogonInfo.ConnectionInfo = oConnectInfo
                            oTable.ApplyLogOnInfo(oLogonInfo)
                        Next
                    End If
                Next
            Next
        End Sub
        Public Shared Sub SetCrystalParams(ByVal sFieldName As String, ByVal iDataType As ParamType, ByVal sVal As String, ByRef oRpt As CrystalDecisions.CrystalReports.Engine.ReportDocument)
            Dim oFieldDefs As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinitions
            Dim oFieldDef As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition
            Dim oParamVals As CrystalDecisions.Shared.ParameterValues
            Dim oDiscreteVal As CrystalDecisions.Shared.ParameterDiscreteValue
            oFieldDefs = oRpt.DataDefinition.ParameterFields
            oFieldDef = oFieldDefs(sFieldName)
            oParamVals = oFieldDef.CurrentValues
            oParamVals.Clear()
            oDiscreteVal = New CrystalDecisions.Shared.ParameterDiscreteValue()
            Select Case iDataType
                Case ParamType.Int
                    oDiscreteVal.Value = System.Convert.ToInt32(sVal)
                Case ParamType.Text
                    oDiscreteVal.Value = sVal
            End Select
            oParamVals.Add(oDiscreteVal)
            oFieldDef.ApplyCurrentValues(oParamVals)
        End Sub
    End Class
    And here's how you would use them:
    ' Create an instance of the Crystal report
    _rptCrystal = New CrystalDecisions.CrystalReports.Engine.ReportDocument()
    _rptCrystal.Load(_oSBO.AddonPath + "\Reports\MyReport.rpt")
    ' Call SetCrystalLogin to see the logon information for all report tables
    CrystalFunctions.SetCrystalLogin(sUser, sPassword, _oSBO.SboCompany.Server, _oSBO.SboCompany.CompanyDB, _rptCrystal)
    ' Set my report parameter value
    CrystalFunctions.SetCrystalParams("MyParam", CrystalFunctions.ParamType.Int, 999, _rptCrystal)
    ' Print the report straight to the printer                          
    _rptCrystal.PrintToPrinter(1, False, 0, 0)
    The other way to approach this solution would be to base your Crystal report on a .NET dataset rather than a database connection. However, as you've already written your report, the code above is going to be simpler to implement.
    Kind Regards,
    Owen

  • Crystal Report Database connection problem in CMC

    Dear All,
    We are using Business Objects XI 3.1, Crystal Report 2008 SP1 for report development. Crystal reports are generated using SAP BW Query.
    Where in, once you have published Crystal report to Enterprise server and open the same using Infoview it gives error saying "database logon failed, check user name password"
    Did checked the database config tab in CMC there was no password and "Prompt user name password" option was enabled as well. when we type the password at the password text box, it is not accepting the same to store at the text box insted keep enpty always.
    Please let know what is the issue and guide me to over come the same.
    Thanks in advance.
    Regards
    Murugesh

    Hi,
    Is the account that runs the services of BOE on your OS able to ping the DB server. It may also lie in the fact that you have to do the correct setup steps for the SAP Integration Kit. Have you installed and configured this between your BW and BOE environment?
    Hope this helps...
    Martijn van Foeken
    Focuzz BI Services
    http://www.focuzz.nl
    http://nl.linkedin.com/in/martijnvanfoeken

  • JSP & Crystal Reports Database Problem

    Hi all,
    I hava problem with refreshing the crystal report web viewer if the report retrieves data from DB.
    If I don't refresh the report, it shows the report with default parameters. But when I refresh the report (I mean viewer.refresh()) it gives an error which says it could not found the JNDI.
    Do you have any idea about it ???
    Thanks in advance.
    Ismail TURK.

    So it can't find the JNDI name.
    What JNDI name is it looking for?
    How are you connecting to the database in the Crystal Reports developer.
    How It works on my machine. [long spiel]
    For some reason I was never able to get a JNDI connection throught the CR10 developer. It kept giving me error messages. But I DID manage to connect to Oracle via the standard Oracle TNSNames interface.
    When I tried loading the report in the browser, it looked for a JNDI name the same as the TNSName. Dunno why.
    The issue is that Tomcat stores the JNDI datasources under java:/comp/env/.
    And I couldn't configure the report to look in that initial context.
    My hack of a solution: load the JNDI datasource myself, and then bind it into the place where Crystal Reports looked:
    So I had
    1 - a TNS Name entry called REPORT_DB which the report designer connected to
    2 - a JNDI entry REPORT_DB defined in Tomcat
    <%
    Context initContext = new InitialContext();
    System.out.println("binding");
    try{
    Object obj = initContext.lookup("REPORT_DB");
    catch(NamingException e){
      System.out.println("Naming exception " + e);
      Context envContext  = (Context)initContext.lookup("java:/comp/env");
      DataSource ds = (DataSource)envContext.lookup("REPORT_DB");
      initContext.bind("REPORT_DB", ds);
    System.out.println("bound");
    %>Maybe this might help you, maybe not.
    Cheers,
    evnafets

  • Random Characters insterted into Crystal Reports string fields

    I'm having a problem where random characters are being inserted into string fields in my crystal reports, I talked to a representative and they are unable to fix the problem, so I'm asking here if someone has a workaround.  The characters are always outside of the normal set of characters, so I'd like to know if there is a way to only allow certain characters in a given field using formulas.  (for example, at a very simple level, i would input a list of "legal characters" and the field in crystal wouldn't display anything but those characters)
    thanks for your time and help

    Sorry, i think I've been a bit imprecise so far
    So these characters ONLY appear when printing the report and not when previewing the report in Crystal Reports?
    They appear when previewing, when actually printing, everything after the characters is cut off
    Are you printing directly from CR or from Enterprise/Infoview or another custom application?
    From CR (both to PDF and paper)
    When did you update your print driver last?
    Not sure, although this may be moot since it also shows up in the preview?
    Have you printed on another printer and does it too exhibit the same behavior?
    Same as above?
    Was the report created by you in CRXI? Are your regional settings set to English (language)?
    Yes I created the report in CRXI, and in terms of the regional settings, I'm not sure but would assume so, how do I check/change this?

  • SAP Crystal reports formula fields

    hi,
        how to use formula fields in crystal report.
                         thanks & regards,vinoth

    Hi Vinoth,
    That's a very vague question.
    You can create formulae via the Field Explorer > Formula option.
    After you save and close the formula editor, you need to drag and drop the formula on the report for it to execute.
    If you need help with a formula, please post the requirement.
    -Abhilash

  • Disable Crystal reports grey fields in the preview

    Dear forum users, I've got an application not written by me (so I do not have source code) that displays a Report in a standard Crystal Report Viewer. In the preview when I click on a field it gets rounded with a grey border, filled with a grey background.
    This is causing me some problems when I use the application via Remote Desktop Connection.
    Since I don't like this feature the question is: can I disable this feature (maybe by changing an entry in the Registry Editor)?
    Best regards
    Alessandro

    Hi Alessandro,
    I think maynot be. whats the screen resolution of your system? If you change it probably you can see that particular grey box clearly.
    or
    try to export that file to excel or pdf. probably you will see the file with you vagueness.
    Regards
    Usama

  • Crystal Reports- Filter field by specific word(s)

    Hello,
    I am not sure if this possible. I have a table memo text field called close description for service incidents. I need a report to only display records where the close description contains the words ( replaced, replace ,swap , UPS, Etc). I dont know how to code this in SQL. And if it can be done are the words case specific?
    Any assistance would be greatly aprreciated
    Thanks all

    OK. Change the SQL Expression code to:
    SELECT CASE
    WHEN CHARINDEX('replaced',"Table"."Database"_Field") > 0
    OR CHARINDEX('replace',"Table"."Database"_Field") > 0
    OR CHARINDEX('swap',"Table"."Database"_Field") > 0
    OR CHARINDEX('UPS',"Table"."Database"_Field") > 0
    THEN 1 ELSE 0
    END
    Then, go to the Record Selection Formula and use the SQL Expression as:
    {%SQL_Exp_Name} = 1
    -Abhilash

  • Crystal Report: Show Field only in Print-Preview

    Dear Experts,
    is it possible to show a field only in the print preview (when the report is generated) without printing this field?
    Thanks for Help.
    Jacqueline

    No, it is not possible to display a report object on screen then suppress it when printing.
    Fuskie
    Who thinks you would have to use 2 reports or use a parameter that offers the option of formatting for view versus for print...

Maybe you are looking for