Dynamic connection string

Hello all
This is Charitha Sharma
i want to know how to and where to store connection string in my applications
we are using multi user environment model system ( network model ) 10 clients connects to server
tech is VB2005 AND ORACLE
i dont want to embedd username and password and host name in connection string
please guide me in real time application developement which one is better one
DSN OR WRITING IT IN ANY FILE OR ......
IF DSN HOW TO ACCESS ITS VALUES IN VB?
OR
WHICH WAY I CAN COMPLETE THIS TASK
THANK YOU

First see whether you've some other configurations also set inside the package for the same properties? ie direct configuration for connection manager properties.
Secondly see if its executed from a job and you're overriding the values through the job properties.
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page

Similar Messages

  • How to create dynamic connection string with variables using ssis.

    Hello,
    Can anyone let me know on how to create dynamic connection string with variables using ssis?
    Any help would be appreciated.

    Hi vinay9738,
    According to your description, you want to connect multiple database from multiple servers using dynamic connection.
    If in this case, we can create a Table in our local database (whatever DB we want) and load all the connection strings.  We can use Execute SQL Task to query all the connection strings and store the result-set in a variable of object type in SSIS package.
    Then use ForEach Loop container to shred the content of the object variable and iterate through each of the connection strings. And then Place an Execute SQL task inside ForEach Loop container with the SQL statements we have to run in all the DB instances. 
    For more details, please refer to the following blog:
    http://sql-developers.blogspot.kr/2010/07/dynamic-database-connection-using-ssis.html
    If there are any other questions, please feel free to let me know.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Report model dynamic connection string

    hi 
    I'm trying to build a report model,which has to connect to different database 
    For ex:
    I've 10 different customers, and i need to connect the selected customer database, 
    Any thoughts how to proceed in this 
    Thanks
    Chezhian 

    Hi Chezhian,
    As per my understanding, I would try the two methods to achieve your requirement: create one report model which contains those databases or create 10 report model, the data source can connect to the corresponding model based on the user. In Reporting Services,
    a report model can only map to a database. So the first method doesn’t work. If we want to connect to a report model, we should browse to a report server or SharePoint site and select a published model. We don’t need a connection string to use a report model
    as a data source. So the second method still doesn’t work.
    To work around the issue, I think we can create 10 report model, each report model corresponding each user’s database and named the user name. Then set Item-Level Permissions of each report model based on the user on report manager. Each user can only see
    his own report model on the report server.
    Or we can create a data source with dynamic connection string, the blog below is for your reference:
    http://blogs.msdn.com/b/bimusings/archive/2006/07/20/673051.aspx
    References:
    Report Model Connection (SSRS)
    Setting Item-Level Permissions on a Report Server
    Hope this helps.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to specifiy the provider to be Oracle.ManagedDataAccess.Client when creating a dynamic connection string with EF Code First from Database?

    I am trying to use the relatively new Code First from Database with the newest EF (6.x) and on an Oracle database (11g, but I have installed the newest ODTwithODAC). First of all, it works fine as long as the connection string is inside the App.Config file. But when I try to build it dynamically in the C# code (or rather, statically at the moment) it fails. I have it working with a dynamically built connection string when doing Model from Database though, so I'm at a loss right now.
    First, I have created a second constructor for the context class that takes a string and does base(connectionString). Then I build the connection string via
    OracleConnectionStringBuilder oracleBuilder = new OracleConnectionStringBuilder();
    oracleBuilder.DataSource = "TEST.BLA.COM";
    oracleBuilder.UserID = "ABC";
    oracleBuilder.Password = "abc";
    oracleBuilder.PersistSecurityInfo = true;
    string connection = oracleBuilder.ToStrin();
    Now trying to open an EntityConnection by giving to it this provider-specific connection string (or even the static one from the App.Config) doesn't work; I get "keyword not supported: user id"). Trying it by creating a context and giving this connection string doesn't work either. I'm pretty sure that this is because I didn't specify the provider to use; after all, it should use the Oracle.ManagedDataAccess.Client provider and not an SQL Server based one.
    I then tried to get around this by using an EntityConnectionStringBuilder on top and specifying the provider keyword there, but then I get "keyword not supported: provider" when using it in the context constructor, and "the 'metadata' keyword is always required" when using it with the EntityConnection constructor.
    As I said above: I bet it's the provider that I have to specify somehow, but I don't know how. The code that does work is the following:
    using (var context = new Model())
    context.Database.Connection.Open();
    context.Database.Connection.Close();
    When I read context.Database.Connection.ConnectionString, it is exactly the provider-specific connection string I created above, but I don't know where to specify the provider again. Do you know of any way to do this? Certainly there must be one.
    PS: I have also posted this question on http://stackoverflow.com/questions/27979454/ef-code-first-from-database-with-managed-oracle-data-access-dynamic-connection because it is quite urgent and I'd like to use Code First from Database. Otherwise I'd have to go "back" to using Model from Database again, which is not ideal because we have updatable views where the .edmx-file has to be edited after every reload of the model, while with Code First from DB inserting into the view automatically works.

    I am trying to use the relatively new Code First from Database with the newest EF (6.x) and on an Oracle database (11g, but I have installed the newest ODTwithODAC). First of all, it works fine as long as the connection string is inside the App.Config file. But when I try to build it dynamically in the C# code (or rather, statically at the moment) it fails. I have it working with a dynamically built connection string when doing Model from Database though, so I'm at a loss right now.
    First, I have created a second constructor for the context class that takes a string and does base(connectionString). Then I build the connection string via
    OracleConnectionStringBuilder oracleBuilder = new OracleConnectionStringBuilder();
    oracleBuilder.DataSource = "TEST.BLA.COM";
    oracleBuilder.UserID = "ABC";
    oracleBuilder.Password = "abc";
    oracleBuilder.PersistSecurityInfo = true;
    string connection = oracleBuilder.ToStrin();
    Now trying to open an EntityConnection by giving to it this provider-specific connection string (or even the static one from the App.Config) doesn't work; I get "keyword not supported: user id"). Trying it by creating a context and giving this connection string doesn't work either. I'm pretty sure that this is because I didn't specify the provider to use; after all, it should use the Oracle.ManagedDataAccess.Client provider and not an SQL Server based one.
    I then tried to get around this by using an EntityConnectionStringBuilder on top and specifying the provider keyword there, but then I get "keyword not supported: provider" when using it in the context constructor, and "the 'metadata' keyword is always required" when using it with the EntityConnection constructor.
    As I said above: I bet it's the provider that I have to specify somehow, but I don't know how. The code that does work is the following:
    using (var context = new Model())
    context.Database.Connection.Open();
    context.Database.Connection.Close();
    When I read context.Database.Connection.ConnectionString, it is exactly the provider-specific connection string I created above, but I don't know where to specify the provider again. Do you know of any way to do this? Certainly there must be one.
    PS: I have also posted this question on http://stackoverflow.com/questions/27979454/ef-code-first-from-database-with-managed-oracle-data-access-dynamic-connection because it is quite urgent and I'd like to use Code First from Database. Otherwise I'd have to go "back" to using Model from Database again, which is not ideal because we have updatable views where the .edmx-file has to be edited after every reload of the model, while with Code First from DB inserting into the view automatically works.

  • Dynamic connection string not working in SSIS package 2008R2

    I am using SSIS package for Import data from excel sheet to SQL DB. In the configuration file I'm using following variables.
    Name scope DataType Value
    DBName package String DB_Master
    Password package String xx
    UserName package String sa
    ServerName package String xxx.xxx.x.xx
    SqlConnectionString package String DataSource=xxx.xxx.x.xxx;UserID=sa;Provider=SQLNCLI10.1;Integrated Security=SSPI;Auto Translate=False;Initial Catalog=DB_Master;Password=xx
    Right click OLEDB ConnectionManager then click properties window below values assign
    ConnectionString - Initial Catalog=DB_Master;DataSource=xxx.xxx.x.xxx;UserID=sa;Provider=SQLNCLI10.1;Integrated Security=SSPI;Auto Translate=False;
    DelayValidation - True
    Expressions -ConnectionString - @[User::SqlConnectionString]
    In SqlConnectionString variable properties window below values assign
    EvaluateAsExpression -True
    Expression -"DataSource=" + @[User::ServerName] + ";UserID=" + @[User::UserName] + ";Provider=SQLNCLI10.1;Integrated Security=SSPI;Auto Translate=False;Initial Catalog=" + @[User::DBName] + ";Password=" + @[User::Password]
    After deploy the package file I change the DBName in SqlConnectionString DB_Master to Master but package execute the files in DB_Master.
    and also if i give invalid ServerName like 198.152.1 but package executed successfully.
    Please tell me where i made mistake. what's goes wrong...?
    I just use variable like below link
    https://anothersqlgeek.wordpress.com/2013/03/28/ssis-dynamic-connections-part-1/comment-page-1/#comment-48

    First see whether you've some other configurations also set inside the package for the same properties? ie direct configuration for connection manager properties.
    Secondly see if its executed from a job and you're overriding the values through the job properties.
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to create dynamic Connection String in SSIS Package???

    Hi
    I created OLEDB Source Connnection String for that Package,
    i need Create OLEDB Destination Connection String Dynamically,
    Same server name,but i need to add DW at the end of the Database
    ex:
    Source database name is Demo,
    Destination database should come DemoDW.
    i need to create Dynamic Destination Connection String..
    any possible to Create 
    Thanks in advance
    Pandiyan
    pandiyan

    Hi Pandiyanpvp,
    According to your description, the OLEDB Destination Connection String should be dynamically based on the OLEDB Source Connection String. They are all the same, except adding “DW” at the end of the Database of OLEDB Source Connection String in OLEDB Destination
    Connection.
    To achieve this requirement, we can create a variable with the Database name of OLEDB Source Connection String, then use expression to control the OLEDB Source and OLEDB Destination Connection Strings. For more details, please refer to the following steps:
    Create a variable named Source with the Database name of OLEDB Source Connection String as value.
    Click the OLEDB Source Connection Manager to navigate to the Properties window.
    Click “…” next to Expressions to add a ConnectionString Property with the expression like below:
    "Data Source=.;Initial Catalog="+@[User::Source] + ";Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False;"
    Click the OLEDB Destination Connection Manager to navigate to the Properties window.
    Click “…” next to Expressions to add a ConnectionString Property with the expression like below:
    "Data Source=.;Initial Catalog="+ @[User::Source] + "DB"+";Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False;"
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Power View with dynamic connection string, but server-side

    We'd like to evaluate using Power View to provide exploratory BI over data output from HDInsight, onto Azure Storage. We need to let users select which segments of data to load but through a web-ui (not Excel on the desktop). We expect to have a standard
    data model, it's just the segments of data that will be dynamically selected by the user. Basically the Power Query will need to be updated dynamically, but on the server-side. Is this scenario currently possible?

    Any suggestions for SFiorito?
    Thanks!
    Ed Price, Power BI & SQL Server Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • JDBC Adapter Receiver dynamic connection string

    Hi,
    I'm developing an IDOC-JDBC scenario and I need to send data to one of the different databases depending of one field in the IDOC. All databases are identical, the only difference is the server where they are. We are using SAP PI 7.0. If you need more information, please report.
    Best Regards,
    Alfredo Lagunar.

    Hi Alfredo,
    no bother to think about dynamic varialble substitution or something like that, which might be possible, might be not. In this case, you just configure several receiver channels and serveral receiver business services. By using the conditioning(XPATH) winthin receiver determination you can route your XML message to the JDBC database with different IP addresses.
    Actually SAP is using the same solution in one of its standard implementation: ELSTER (Electronic Tax Claim, in german Elektronische Steuererklärung). The only difference is the receivers are HTTP endpoint, not JDBC. But the idea is the identical: they are all having different IPs, like your databases.
    Hope it inspires.
    Regards,
    Chen

  • Database connection string dynamic

    Hello everybody,
    My application should do some tests that user choses.
    For each test type I should save the database in a file with different name, something like : Report_YYYY_MM_DD_Test_x, without stopping the execution of the application.
    My problem is that i cannont rename the database after Teststand wrote in it. I must stop first the application and then I can rename it.
    I tried to build dynamic connection strings and to prepare the database before Teststand write it. But I saw that after the first acces, despite of new connection string, Testand write further in the database described in the first connection string. Also seems that the handle to database once established, will be released at the end of test. I could close the connection to the DB but i don't know if it is possible.
    for any ideea how to handle this situation i would be grateful

    Hi Harleen Kaur Chadha,
    I understand your requirement is access 5-6 database on same server using one JDB receiver channel. I think, it is possible. SAP Help [Link|http://help.sap.com/saphelp_nwpi711/helpdata/en/44/7c24a75cf83672e10000000a114a6b/frameset.htm ]. In receiver JDB channel select Message Protocol : u201CNative SQL Stringu201D. Then you have make sure that the payload coming to this JDBC receiver channel should look like this
    INSERT INTO DatabaseName : tableName 
    (column-name1, column-name2, column-name3)
    VALUES(u2018column-value1u2019, u2018column-value2u2019, u2018column-value3u2019)
    But, the mapping program you are using now, should generate the String (shown above). And SAP says this protocol is primarily for test purposes.
    FYI. If you select Message Protocol: "XML SQL Format", finally it would be converted to string (shown above) will be sent to database.
    Regards,
    Raghu_Vamsee

  • Chnage connection string after moving database

    re-configure database after moving

    Hi marky101,
    I would suggest you elaborate your scenario/environment/issue with more detail, so that the community members will help you in a effecient manner.
    If you want to dynamic change the data connection string in your C# application, please take a look at the following article:
    Dynamic Connection String:
    http://www.codeproject.com/Articles/755380/Dynamic-Connection-String
    If you have any concern regarding move a database from one server to another server, please see the article below:
    Move a database from one server to another server in SQL Server 2008:
    http://blogs.msdn.com/b/sreekarm/archive/2009/09/11/move-a-database-from-one-server-to-another-server-in-sql-server-2008.aspx
    Elvis Long
    TechNet Community Support

  • 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]

  • Dynamically Setting a Variable from a Connection String that has been set by a Config File

    Hi Guys
    I'm setting up a Master / Slave (Parent / Child) dtsx environment but I'm unable to work out how to dynamically set a variable in the Master dtsx from a connection string that has had its value set by a config file. I'm sure it's possible.
    Below is the what I'm hoping to achieve. I've set up everything apart from the highlighted section.
    Any ideas?

    First, what version of SQL Server are you using?
    You could switch the problem around.  You could set the value of a variable from the config file, then it is easy to use that variable as the connection string source for your connection manager.  At the same time you can use a parent variable
    configuration to map that variable to variables in your child package.
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • Dynamic excel connection string

    Hi, 
    I have excel file as source, where the file name can be anything; so to fetch the data from the excel file, I wanted to create a dynamic excel connection string. 
    So these are the following steps I have followed:
    1. For Each Loop: 
    Step 2:
    Step 3: Excel Connection string
    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\Product\Marketing__Products___Services.xlsx;Extended Properties="EXCEL 12.0 XML;HDR=YES";
    Connection String Expression : @[User::SourceFolder]+ @[User::SourceFile]
    And Below is the error I'm getting
    TITLE: Microsoft Visual Studio
    The component reported the following warnings:
    Error at PlanningIT_Service [Connection manager "Excel Connection Manager"]: The connection string format is not valid. It must consist of one or more components of the form X=Y, separated by semicolons. This error occurs when a connection string
    with zero components is set on database connection manager.
    Error at PlanningIT_Service: The result of the expression "@[User::SourceFolder]+ @[User::SourceFile]" on property "\Package.Connections[Excel Connection Manager].Properties[ConnectionString]" cannot be written to the property. The expression
    was evaluated, but cannot be set on the property.
    Choose OK if you want to continue with the operation.
    Choose Cancel if you want to stop the operation.
    BUTTONS:
    OK
    Cancel

    Hi,
    *) Make sure file names are retrieved properly:
    A.txt if you have Name and extension under Collection tab - > Retrieve file name
    A  if you have Name only under Collection tab - > Retrieve file name
    C:\Users\sathya\Desktop\Source_Folder\A.txt  if you have Fully qualified under Collection tab - > Retrieve file name
    *) variable property - Set EvaluateAsExpression = True
    Try below links for examples:
    http://msdn.microsoft.com/en-us/library/ms345182.aspx
    http://mikedavissql.com/2013/09/16/loop-through-excel-files-in-ssis/
    http://www.allaboutmssql.com/2012/09/sql-server-integration-services-rename.html
    sathya - www.allaboutmssql.com ** Mark as answered if my post solved your problem and Vote as helpful if my post was useful **.

  • ISQL*PLUS dynamic reports - how to pass connect string in the URL

    When we run dynamic reports thru ISQL*PLUS, does anyone know how
    to pass the connect string info in the URL
    The following is the code from ISQL*PLUS users guide but it
    dosen't show how to pass the connect string
    when I tried to pass hr/your_secret_password@dbserver for userid
    I got an error msg
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    <HTML>
    <HEAD>
    <TITLE>iSQL*Plus Dynamic Report</TITLE>
    </HEAD>
    <BODY>
    <H1>iSQL*Plus Report</H1>
    <H2>Query by Employee ID</H2>
    <FORM METHOD=get ACTION="http://host.domain/isqlplus">
    <INPUT TYPE="hidden" NAME="userid"
    VALUE="hr/your_secret_password">
    <INPUT TYPE="hidden" NAME="script"
    VALUE="http://host.domain/employee_id.sql">
    Enter employee identification number: <INPUT TYPE="text"
    NAME="eid" SIZE="10">
    <INPUT TYPE="submit" VALUE="Run Report">
    </FORM>
    </BODY>
    </HTML>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Thanks
    Jay

    The form you use should work when your change
    "hr/your_secret_password" to a valid username, password
    and connect identifier like "hr/hr@MYDB". Don't forget to
    configure MYDB in your tnsnames.ora file on the machine that has
    the iSQL*Plus server.
    What was the error you got?
    The full URL syntax did seem to go missing from the 9.0.1 doc.
    See below for the full syntax. This should be appearing in a
    forthcoming FAQ.
    - CJ
    What syntax can I use to run an iSQL*Plus Dynamic Report?
    You can run a dynamic report by entering the report URI in the
    location field of your browser, or by making the report server a
    link or the action for an HTML form. The iSQL*Plus 9i Release 1
    documentation has examples of these.
    The general syntax for running a dynamic report is:
    {uri}?[userid=logon&]script=location[&param...]
    where uri
    Represents the Uniform Resource Identifier (URI)
    of the iSQL*Plus Server, for example:
    http://host.domain/isqlplus
    where logon
    Represents the log in to the database to which you
    want to connect:
    {username[/password][@connect_identifier]}
    where location
    Represents the URI of the script you want to run.
    The syntax is:
    http://[host.domain/script_name]
    The host serving the script does not have to be
    the same as the machine running the iSQL*Plus server.
    where param
    Specifies the named parameters for the script you
    want to run.
    Named parameters consist of varname=value pairs.
    iSQL*Plus will define the variable varname to equal value prior
    to executing the script e.g.
    ...script=http://server/s1.sql&var1=hello&var2=world
    This is equivalent to the SQL*Plus commands:
    SQL> define var1=hello
    SQL> define var2=world
    SQL> @http://server/s1.sql
    iSQL*Plus, SQL*Plus and SQL keywords are reserved
    and must not be used as the variable names (varname). Note also,
    that since variables are delimited by the ampersand character,
    there is no requirement to enclose space delimited values with
    quotes. However, to embed the ampersand character itself in the
    value, it will be necessary to use quotes.
    For compatibility with older scripts using the &1
    variable syntax, varname may be replaced with the equivalent
    variable position as in:
    ...script=http://server/s1.sql&1=hello&2=world
    Note the & is the URL parameter separator and not
    related to the script's substitution variable syntax.
    Commands and script parameters may be given in any
    order in the dynamic report URI. However, please note that if any
    parameters begin with reserved keywords such as "script" or
    "userid" then it may be interpreted as a command rather than a
    literal parameter.

  • Changing Connection String dynamically at runtime

    I am using the Crystal Report Viewer control in in a Visuall Studio 2008 C# project.  The reports are created inside of Visual Studio 2008, and will be running against an InterSystems Cache database.  I have to use an ODBC (RDO) connection and use a connection string.
    I have seen many examples of how to update the connection string at runtime if it is SQL server (or some flavor thereof), but nothing for an ODBC (RDO) connection to a NON-MSSQL database.
    The problem when I update the connection string for each of the tables in the report, the report will either not run and display a window -- tiled 'Datbase Login' -- that has the Server, Database, Username, and Password fields on the window, OR, it will run but not against the database that was specified at runtime (it uses the connection stored in the report).
    Code Sample #1 (This is using the connection string, and will cause a the "Database Login" window to be displayed - the first scenario from above)
    rd = new ReportDocument();
    // Load the report
    rd.Load(fileName, OpenReportMethod.OpenReportByDefault);
    rd.Refresh();
    // Create the connection object
    ConnectionInfo connectionInfo = CreateConnection(Server, Port, ServerNamespace, Username, Password);
    // Set the connection info on each table in the report
    SetDBLogonForReport(connectionInfo, rd);
    SetDBLogonForSubreports(connectionInfo, rd);
    private static ConnectionInfo CreateConnection(string Server,
                                                   int Port,
                                                   string ServerNamespace,
                                                   string Username,
                                                   string Password)
            ConnectionInfo connectionInfo = new ConnectionInfo();
            string connString = "DRIVER=InterSystems ODBC;SERVER=" + Server
                                                      + ";PORT=" + Port
                                                      + ";DATABASE=" + ServerNamespace
                                                      + ";UID=" + Username
                                                      + ";PWD=" + Password;
            connectionInfo.IntegratedSecurity = false;
            connectionInfo.UserID = Username;
            connectionInfo.Password = Password;        //In examples that I have seen, this is the actual connection string, not just the server name
            connectionInfo.ServerName = connString;          connectionInfo.DatabaseName = ServerNamespace;
            connectionInfo.Type = ConnectionInfoType.CRQE;
            return connectionInfo;
    private static void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
            foreach (CrystalDecisions.CrystalReports.Engine.Table table in reportDocument.Database.Tables)
                TableLogOnInfo tableLogonInfo = table.LogOnInfo;
                tableLogonInfo.ConnectionInfo = connectionInfo;
                table.ApplyLogOnInfo(tableLogonInfo);
    private static void SetDBLogonForSubreports(ConnectionInfo connectionInfo, ReportDocument reportDocument)
            foreach (Section section in reportDocument.ReportDefinition.Sections)
                foreach (ReportObject reportObject in section.ReportObjects)
                    if (reportObject.Kind == ReportObjectKind.SubreportObject)
                        SubreportObject subreportObject = (SubreportObject)reportObject;
                        ReportDocument subReportDocument = subreportObject.OpenSubreport(subreportObject.SubreportName);
                        SetDBLogonForReport(connectionInfo, subReportDocument);
    Sample #2 (the same as Sample #1 above, only the ConnectionInfo method is different - which is all that I included here)
    private static ConnectionInfo CreateConnection(string Server,
                                                    int Port,
                                                   string ServerNamespace,
                                                   string Username,
                                                   string Password)
            ConnectionInfo connectionInfo = new ConnectionInfo();
            string connString = "DRIVER=InterSystems ODBC;SERVER=" + Server
                                                      + ";PORT=" + Port
                                                      + ";DATABASE=" + ServerNamespace
                                                      + ";UID=" + Username
                                                      + ";PWD=" + Password;
            connectionInfo.Attributes.Collection.Add(new NameValuePair2(
                              DbConnectionAttributes.CONNINFO_DATABASE_DLL, DbConnectionAttributes.DATABASE_DLL_CRDB_ODBC));
            connectionInfo.Attributes.Collection.Add(new NameValuePair2(
                              DbConnectionAttributes.QE_DATABASE_NAME, ServerNamespace));
            connectionInfo.Attributes.Collection.Add(new NameValuePair2(
                              "QE_DatabaseType", "ODBC (RDO)"));
            DbConnectionAttributes attributes = new DbConnectionAttributes();
            attributes.Collection.Add(new NameValuePair2(
                              DbConnectionAttributes.CONNINFO_CONNECTION_STRING, connString));
            attributes.Collection.Add(new NameValuePair2(
                              "Server", Server));
            attributes.Collection.Add(new NameValuePair2(
                              "UseDSNProperties", false));
            connectionInfo.Attributes.Collection.Add(new NameValuePair2
    (                          DbConnectionAttributes.QE_LOGON_PROPERTIES, attributes));
            connectionInfo.Attributes.Collection.Add(new NameValuePair2(
                              DbConnectionAttributes.QE_SERVER_DESCRIPTION, Server));
            connectionInfo.Attributes.Collection.Add(new NameValuePair2(
                              "QE_SQLDB", true));
            connectionInfo.Attributes.Collection.Add(new NameValuePair2(
                              DbConnectionAttributes.CONNINFO_SSO_ENABLED, false));
            connectionInfo.IntegratedSecurity = false;
            connectionInfo.UserID = Username;
            connectionInfo.Password = Password;
            connectionInfo.ServerName = connString;
            connectionInfo.DatabaseName = ServerNamespace;
            connectionInfo.Type = ConnectionInfoType.CRQE;
            return connectionInfo;
    I have also tried setting connectionInfo.ServerName equal to just the real server name, but that didn't work either.
    After the above operations are performed, I simply assign the returned ReportDocument object to the Crystal Viewer control.  If I don't call the above functions, and just set the ReportDocument source (using whatever connection string was embedded in the report originally), the report runs as expected.  Only when I attempt to update the connection string, the report will not execute.  Please advise.  Thanks!

    I am using the Crystal Report Viewer control in in a Visuall Studio 2008 C# project.  The reports are created inside of Visual Studio 2008, and will be running against an InterSystems Cache database.  I have to use an ODBC (RDO) connection and use a connection string.
    I have seen many examples of how to update the connection string at runtime if it is SQL server (or some flavor thereof), but nothing for an ODBC (RDO) connection to a NON-MSSQL database.
    The problem when I update the connection string for each of the tables in the report, the report will either not run and display a window -- titled 'Datbase Login' -- that has the Server, Database, Username, and Password fields on the window, OR, it will run but not against the database that was specified at runtime (it uses the connection stored in the report).
    Code Sample #1 (This is using the connection string, and will cause a the "Database Login" window to be displayed - the first scenario from above) -- The code samples appear to be too long to post, so I will add them as seperate replies.
    rd = new ReportDocument();
    // Load the report
    rd.Load(fileName, OpenReportMethod.OpenReportByDefault);
    rd.Refresh();
    // Create the connection object
    ConnectionInfo connectionInfo = CreateConnection(Server, Port, ServerNamespace, Username, Password);
    // Set the connection info on each table in the report
    SetDBLogonForReport(connectionInfo, rd);
    SetDBLogonForSubreports(connectionInfo, rd);
    private static ConnectionInfo CreateConnection(string Server, int Port, string ServerNamespace, string Username, string Password)
            ConnectionInfo connectionInfo = new ConnectionInfo();
            string connString = "DRIVER=InterSystems ODBC;SERVER=" + Server + ";PORT=" + Port + ";DATABASE=" + ServerNamespace + ";UID=" + Username + ";PWD=" + Password;
            connectionInfo.IntegratedSecurity = false;
            connectionInfo.UserID = Username;
            connectionInfo.Password = Password;        //In examples that I have seen, this is the actual connection string, not just the server name
            connectionInfo.ServerName = connString;          connectionInfo.DatabaseName = ServerNamespace;
            connectionInfo.Type = ConnectionInfoType.CRQE;
            return connectionInfo;
    // Code smple continued in the next reply

Maybe you are looking for