Linq2sql Connection string for crystal report. Report requires logon

If I take out the connection string info the report runs fine from my machine but any other user it asks for logon information so I am trying to add the connection info. The line that is not compiling is `cr1.SetDatabaseLogon(connection, cr1);`
What am I doing wrong? Any help would be appreciated!
    private void launchReport(int pKReport)
        using (DataClasses1DataContext db = new DataClasses1DataContext())
            var query = (from s in db.expenseHdrs
                         join d in db.expenseDtls on s.rptNo equals d.rptNo
                         where s.rptNo == pKReport
                         from g in db.employees
                         join r in db.expenseHdrs on g.pk equals r.empPk
                         select new
                             s.period,
                             s.description,
                             s.department,
                             s.rptNo,
                             s.reimbursement, g.name,
                             d.expDate,
                             d.expType,
                             d.expDesc
            CrystalReport1 cr1 = new CrystalReport1();
            ConnectionInfo connection = new ConnectionInfo();
            connection.DatabaseName = "intranet";
            connection.UserID = "sa";
            connection.Password = "*****";
            cr1.SetDatabaseLogon(connection, cr1);
            cr1.SetDataSource(query);
            crystalReportViewer1.ReportSource = cr1;
I also tried changing the code after my query to below but I still have the exact same problem as before when I didnt have the connection string credentials. On every user but myself I get the same sql server login screen and no matter what I enter it fails. I think it is due to there being no database name which it will not allow me to manually enter.
     CrystalReport1 cr1 = new CrystalReport1();
                cr1.FileName = @"C:\Intranet\CrystalReport1.rpt";
                ConnectionInfo connectionInfo = new ConnectionInfo();
                connectionInfo.ServerName = "svr-sql";
                connectionInfo.DatabaseName = "intranet";
                connectionInfo.UserID = "sa";
                connectionInfo.Password = "*****";
                SetDBLogonForReport(connectionInfo, cr1);
                cr1.SetDataSource(query);
                crystalReportViewer1.ReportSource = cr1;
    private void SetDBLogonForReport(ConnectionInfo connectionInfo, CrystalReport reportDocument)
            Tables tables = reportDocument.Database.Tables;
            foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
                TableLogOnInfo tableLogonInfo = table.LogOnInfo;
                tableLogonInfo.ConnectionInfo = connectionInfo;
                table.ApplyLogOnInfo(tableLogonInfo);

The code I use is as follows:
Dim crDatabase As Database
Dim crTables As Tables
Dim crTable As Table
Dim crTableLogOnInfo As TableLogOnInfo
Dim crConnectionInfo As ConnectionInfo
Dim crReportDocument As ReportDocument
CrConnectionInfo = New ConnectionInfo
With crConnectionInfo
.ServerName = "dbconn1"
.DatabaseName = "Pubs"
.UserID = "vantech"
.Password = "vantech"
crDatabase = crReportDocument.Database
crTables = crDatabase.Tables
End With
crDatabase = crReportDocument.Database
crTables = crDatabase.Tables
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
This assumes that there are no subreports (or at least that if there are subreports, they use identical db connection info).
My recommendation would be to test the above code with a simple test report (one table, one field). If you have subreports, you may need to set the logon for those also - depends on how the subreports are implemented. Subreport logon code would be something like this:
Dim crSubreportDocument As ReportDocument
crSubreportDocument = crReportDocument.OpenSubreport("Ron")
crConnectionInfo = New ConnectionInfo
With crConnectionInfo
.ServerName = "Rcon1"
.DatabaseName = "Northwind"
.UserID = "vantech"
.Password = "vantech"
End With
crDatabase = crSubreportDocument.Database
crTables = crDatabase.Tables
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
Alternatively, you could download the db logon writing utility that is attached to this KB and implement that.
- Ludek
Follow us on Twitter
Got Enhancement ideas? Try the SAP Idea Place
Share Your Knowledge in SCN Topic Spaces

Similar Messages

  • How to dynamically set connection string for report in C# code?

    Hi,
    I have installed CRVS2010. I have created new Crystal Report WPF Application and new report. I would like to set connection string for report in code dynamically.
    Is this possible?
    Thanks
    Ivana

    Lots of posts in this forum on how to set database connections. WPF should not be a consideration as it's just a viewer. The report engine is still the same. Search these forums. Use the search box at the top right corner of this page. Look at samples here:
    https://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsfor.NETSDK+Samples
    Note that none of the samples above are using WPF, but like I said, the WPF is just a different viewer and will not impact how the report engine logs on to a database. (I think of it as a gray car vs. a red car. Same engine, just the color is different)
    Ludek
    Follow us on Twitter http://twitter.com/SAPCRNetSup
    Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

  • Report Designer odbc connection string for data source using a parameter

    I am using stand alone report designer 3 for the present and have a question/problem regarding the odbc connection string for MySQL when setting up the data-source
    I need to be able to enter a parameter which is the database name i.e. BOE-201401 or say BOE-201312 etc  from a list of databases the user can choose from.
    at present the odbc connection string points to BOE-201402
    the connection string is at present  Dsn=Development Server for MYsql;description=MYSQL;server=ldndw01;database=BOE-201402;port=3306
    my parameter has the name BOE_DATABASE
    and in an expression it is  as such
    =Parameters!BOE_DATABASE.Value
    I want to point the datasource for the report to the parameter value before the user sees the report.

    Hi Leslie,
    Based on your description, we want to design a report with a dynamic DataSource connection string. There are the basic steps below for your reference:
    Create report with static database.
    Change data source to report parameter.
    Send new database connection string as a report parameter. 
    More detail information, please refer to the following blog: Dynamic Database in SSRS 2008.
    http://haseebmukhtar.wordpress.com/2011/11/09/dynamic-database-in-ssrs-2008/
    Regards,
    Alisa Tang
    Alisa Tang
    TechNet Community Support

  • Hi expert,Incorrect connection string for addon

    hi expert
    I am getting error when connect  my addon in client pc.
    my addon working fine in server at client side.
    but in client i m getting error "Incorrect connection string for addon".in my addon i am using crystal report and two sap b1 user form. thanks in adva.
    regards
    Rajkumar Gupta
    Edited by: Rajkumar Gupta on May 23, 2009 12:49 PM

    Hi Rajkumar,
    Sometimes this error message is related to the UI server. Please see note 808354 or 852031 and see if this has any effect.
    If not, please post up a code sample so we can take a look,
    Regards,
    Niall

  • Building Connection string in Crystal 10

    Hi,
    How to build a connection string in Crystal 10 using DSN as data source?
    I tried the following syntax, but failed to establish connection...
    Driver={SQL Server};Server=;Uid=<username>;Pwd=<pwd>;
    Help me to fix this out.
    Thanks
    Viswa

    Hey Prathamesh,
    I was asking the option available in the crystal client itself!
    In the data source selection, there is three options available:
    1. Data Source Name
    2. File name DSN
    3. Enter Connection String
    I asked about the 3rd option in that dialog; in which we can directly enter the connection string for the data source connection. I don't think this is related with SDK Application Development.
    Thanks
    Viswa
    Edited by: Viswanathan Madhavan on Nov 27, 2008 3:08 AM

  • Save Query - An error occurred while creating connection strings for the query

    A workbook trying to edit and reload I get the following error "Save Query - An error occurred while creating connection strings for the query" No Power Pivot data model or anything.

    I am getting the same error when editing a Power Query in an Excel spreadsheet. It happens when I change a Group By step to do a Sum instead of Count Rows.

  • How to change connection string for a form created with b1de

    Hi all
    i've created a form using the Code Generator tool ob B1DE
    My question is how can i set the connection string to a different server and database. doing so after the creation wizard has finished?

    Hi,
    Why do you need to change the connection string? What are you calling "connection string for a form"???
    The only connection string I now about is the one used to connect to the UI API... and this one is fixed for all apps in debug mode and given as parameter when your addon is registered in B1.
    The connection string is filled in the code of your generated addon.
    Please go to the main class of your addon, in the main method you have the following code where the connection string is filled either with the command line parameters (release mode) or with the fixed value given by SAP. This code doesn't need to be changed...
            public static void Main()
                int retCode = 0;
                string connStr = "";
                bool diRequired = true;
                // CHANGE ADDON IDENTIFIER BEFORE RELEASING TO CUSTOMER (Solution Identifier)
                string addOnIdentifierStr = "";
                if ((System.Environment.GetCommandLineArgs().Length == 1)) {
                    connStr = B1Connections.connStr;
                else {
                    connStr = System.Environment.GetCommandLineArgs().GetValue(1).ToString();
                try {
                    // INIT CONNECTIONS
                    retCode = B1Connections.Init(connStr, addOnIdentifierStr, diRequired);
    Regards
    Trinidad.

  • What are the username, password and connect string for Designer 6.1.1?

    So that we may better diagnose DOWNLOAD problems, please provide the following information.
    - Server name
    - Filename
    Oracle designer6.1.1
    - Date/Time
    - Browser + Version
    IE 6.0
    - O/S + Version
    Win 98
    - Error Msg
    ORA-12154:TNS:could not resolve service name.
    RME-00220:Fail to connect to repository
    These error messages were shown after I entered system, manager and internal, respectively.

    Hi YungJen Chen,
    There is no general username, password and connect string for
    Designer 6i Release 4.1.1.
    First, you install the client tools using the Installer. See also the
    Designer Installation Guide, Chapter 1, 'Client Side installation'.
    Second, you install the repository into an existing database, using
    the Designer Installation Guide, Chapter 2, 'Server-side installation,
    migration and upgrade'.
    The Installation Guide provides step by step instructions on what
    users you need to create for various purposes. Any database users
    you may need to use such as System or Sys will use the password
    given when you installed the database, or whatever passowrd you
    changed it to since.
    The Installation Guide is available as part of the download, or from
    your Windows Start Menu once the Designer client tools are installed
    or from the Designer Documentation page here on OTN.
    Hope this helps. Regards,
    Dominic Battiston
    Designer/JDeveloper Product Management

  • What are the username, password, and connect string for Designer6i R4.1.1

    As the title, I tried system, manager and internal.
    But it did not work out.
    Thank you for your help.

    Hi YungJen Chen,
    There is no general username, password and connect string for
    Designer 6i Release 4.1.1.
    First, you install the client tools using the Installer. See also the
    Designer Installation Guide, Chapter 1, 'Client Side installation'.
    Second, you install the repository into an existing database, using
    the Designer Installation Guide, Chapter 2, 'Server-side installation,
    migration and upgrade'.
    The Installation Guide provides step by step instructions on what
    users you need to create for various purposes. Any database users
    you may need to use such as System or Sys will use the password
    given when you installed the database, or whatever passowrd you
    changed it to since.
    The Installation Guide is available as part of the download, or from
    your Windows Start Menu once the Designer client tools are installed
    or from the Designer Documentation page here on OTN.
    Hope this helps. Regards,
    Dominic Battiston
    Designer/JDeveloper Product Management

  • Connection string for Oracle in instantclient11_1 Driver without TNS

    We have Oracle DB without tnsnames.ora.
    We are able to connect to the DB using sqlplus from a command line with the following connection string:
    username/Password@DomainAdress:Port/DataBaseName.DomainAdress
    SYS/****@computerName.Domain.net:1523/DataBaseName.computerName.Domain.net
    If we try to connect from the command line only with the DB name and not the FQDN – the connection fails.
    We would like to connect  using Driver={Oracle in instantclient11_1} We tried the following connection string:
    Driver={Oracle in instantclient11_1};Dbq= computerName.Domain.net:1523/ DataBaseName.computerName.Domain.net;Uid=SYS;Pwd=**** as sysdba
    We got the following Error:
    [Oracle][ODBC][Ora]ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
    What should be the right connection string for Oracle in instantclient11_1 Driver?

    Thanks for the confirmation.

  • Connection String with Crystal Report XI R2

    Hello,
    I am having an issue with Crystal Reports XI R2 and figured this would be a good place to start and post my question.
    I created a report in Crystal Reports XI and am now trying to pass the user id and password so that the user can just run the report. I attempted to use the Crystal Report connection string setup but receive an Microsoft ODBC error when trying to use that.
    My question is how can you pass a userid and password to crystal report XI so that when you open the report it runs without prompting the user? I do not have access to .NET. Can this be done using Crystal Reports XI only?
    Thanks in advance for your help
    Shaun

    Hi Shawn,
    Standalone CR can only do that if using a URL to open a report in BOE.
    For CR Designer itself the only option is to turn on Trusted Authentication in your Server, used Mixed mode and then import all of your users into SQL Server. Refer to MS's Help file on how to.
    Now when the user runs the reports CR will simply pass the local user info to SQL Server and no prompting will be required. We still respect DB security so if the user is not allowed to access the table then CR respects that.
    Thank you
    Don

  • Connect String for the front end app to access Lite Database in the Client

    Hi,
    I have been using an app developed in VB.net for accessing the Oracle Lite Database from the client machine. Can anyone please help me out how to set the Connect String in the config file of my front end app to access the Oracle Lite Database from my client machine. Do anyone have the syntax of the connect string to access the lite database in client machine.
    Thanks a lot in advance.

    Hi...
    -->Select example
    create or replace procedure get_emp(rc out sys_refcursor)
    is
    begin
    open rc for select * from emp;
    end;
    -->DML example
    create or replace procedure do_dml_emp(pempid in number,
    pempname varchar2,
    result out number)
    is
    begin
    insert into emp(empid,empname) values(pempid,pempname) returning empid into result;
    exception
    when others then
    result:=-1;
    end;
    -->DDL example
    create or replace procedure ddl_emp(colname varchar2,
    coltype varchar2,
    result out number)
    is
    begin
    result:=-1;
    execute immediate 'alter table emp add column ' || colname || ' ' || coltype ;
    result:=1;
    end;

  • The connection string for coded UI Data driven test using excel data source is not working

    Hello,
    I am using the visual studio 2012 coded UI test, i added the following connection strings to connect to an excel data source:
    [DataSource("System.Data.Odbc", "Dsn=Excel Files;Driver={Microsoft Excel Driver (*.xls)};dbq=C:\\Users\\shaza.said.ITWORX\\Desktop\\Automation\\On-track Automation Framework\\On-track_Automation\\Automation data file.xls;defaultdir=.;driverid=790;maxbuffersize=2048;pagetimeout=5;readonly=true",
    "Sheet1$", DataAccessMethod.Sequential), TestMethod]
    [DataSource("System.Data.Odbc", "Dsn=Excel Files;dbq=|DataDirectory|\\Automation data file.xls;defaultdir=C:\\Users\\shaza.said.ITWORX\\Desktop\\Automation\\On-track Automation Framework\\On-track_Automation\\Automation data file.xls;driverid=1046;maxbuffersize=2048;pagetimeout=5",
    "Sheet1$", DataAccessMethod.Sequential), TestMethod]
    But i get the following error:
    "The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see "Troubleshooting Data-Driven Unit Tests" (http://go.microsoft.com/fwlink/?LinkId=62412) in the MSDN Library.
    Error details: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
    Thanks,
    Shaza

    Thanks for Adrian's help.
    Hi shaza,
    From the error message, I suggest you can refer the Adrian's suggestion to check the date source connection string correctly.
    In addition, you can refer the following about how to Create a Data-Driven Coded UI Test to check your issue:
    http://msdn.microsoft.com/en-us/library/ee624082.aspx
    Or you can also try to use a Configuration File to Define a Data Source for coded UI test.
    For example:
    <?xml
    version="1.0"
    encoding="utf-8"
    ?>
    <configuration>
    <configSections>
    <section
    name="microsoft.visualstudio.testtools"
    type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection,
    Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    </configSections>
    <connectionStrings>
    <add
    name="ExcelConn"
    connectionString="Dsn=Excel Files;dbq=E:\Unit Test\AddClass\AddUnitTest\add.xlsx;defaultdir=.;
    driverid=790; maxbuffersize=2048; pagetimeout=60;"
    providerName="System.Data.Odbc"/>
    <add
    name="ExcelConn1"
    connectionString="Dsn=Excel Files;dbq=E:\Unit Test\AddClass\AddUnitTest\sum.xlsx;defaultdir=.;
    driverid=790;maxbuffersize=2048;pagetimeout=60"
    providerName="System.Data.Odbc"/>
    </connectionStrings>
    <microsoft.visualstudio.testtools>
    <dataSources>
    <add
    name="ExcelDS_Addition"
    connectionString="ExcelConn"
    dataTableName="Addition$"
    dataAccessMethod="Sequential"/>
    <add
    name="ExcelDS_Multiply"
    connectionString="ExcelConn1"
    dataTableName="Multiply$"
    dataAccessMethod="Sequential"/>
    </dataSources>
    </microsoft.visualstudio.testtools>
    </configuration>
    For more information, please see:https://msdn.microsoft.com/en-us/library/ms243192.aspx
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to set ApplicationIntent=ReadOnly in Connection String for SharePoint 2013

    SharePoint 2013 and SQL Server 2012 allows us some additional options to create HA and DR sites through AlwaysOn Availablibity Groups and Listeners.  Problem that I'm having is that I have a DR site that is at a different location.  Microsoft
    recommends not to stretch the farm across different locations, so I've created a separate farm for DR.  I have my content database in an Availability Group so that is Asynchronously commits data changes across the 2 locations.  My DR site
    connects to the content database through a Listener. 
    Since the DR site is connecting to the content database through the Listener, it is connecting the primary replica.  In order to connect to the Read Only secondary replica, I need to add "ApplicationIntent=ReadOnly"
    to the connection string.  How do you do that?

    It supports a secondary being Readable, that is all it is telling you. It does not support, nor implement, Read-Intent. This is expected behavior. You can look at the Conn Strings via PowerShell, of course:
    $db = get-spdatabase | where {$_.TypeName -like "*Config*"}
    $db.DatabaseConnectionString
    Data Source=SPSQL;Initial Catalog=Config;Integrated Security=True;Enlist=False;
    Pooling=True;Min Pool Size=0;Max Pool Size=100;Connect Timeout=15
    Trevor Seward
    Follow or contact me at...
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • The Connection String for the Query Log table is automatically encrypted.

    When I try to use the Usage Based Optimization to apply Aggregation Design to my measure group, it shows me the following
    error message.
    The connection string cannot be found. Open Microsoft SQL Server Management Studio and, in the Analysis Server Properties
    page, check the value of the Log\QueryLog\QueryLogConnectionString
    property.
    I encountered this error like two weeks ago.  At that time I just reset the connection string and every things seem
    to be fine.  A week ago, I successfully applied the Usage Based Optimization for one of my cubes.  However when I tried to apply UBO for my other cubes today, I encountered the same issue again!  I believe no one has changed the property of
    the connection string.
    Also if I query the Query Log table, I can see those latest queries made by the users.  I'm sure the queries are still
    logging into this table.
    This is really strange.  Anyone else has encountered the same issue?  Thanks.

    Hello Thomas,
    I encounterd this issue. And I am struggling trying to solve this problem. If you have resolved this issue and I guess you must've, because this post is two years old, could you kindly post how you resolved this issue?
    Thanks in advance
    Best Regards,
    Neeraja

Maybe you are looking for