コード例 #1
0
    public static TableLogOnInfo GetODBCTableLogOnInfo(string ODBCName, string serverName, string databaseName, string userID, string password)
    {
        CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag connectionAttributes = new CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag();

        connectionAttributes.EnsureCapacity(3);
        connectionAttributes.Add(DbConnectionAttributes.CONNINFO_CONNECTION_STRING, string.Format("DSN={0}", ODBCName));
        connectionAttributes.Add("Server", serverName);
        connectionAttributes.Add("UseDSNProperties", false);

        DbConnectionAttributes attributes = new DbConnectionAttributes();

        attributes.Collection.Add(new NameValuePair2("Database DLL", "crdb_odbc.dll"));
        attributes.Collection.Add(new NameValuePair2("QE_DatabaseName", databaseName));
        attributes.Collection.Add(new NameValuePair2("QE_DatabaseType", "ODBC (RDO)"));
        attributes.Collection.Add(new NameValuePair2("QE_LogonProperties", connectionAttributes));
        attributes.Collection.Add(new NameValuePair2("QE_ServerDescription", serverName));
        attributes.Collection.Add(new NameValuePair2("QE_SQLDB", true));
        attributes.Collection.Add(new NameValuePair2("SSO Enabled", false));

        ConnectionInfo connectionInfo = GetConnectionInfo(serverName, databaseName, userID, password);

        connectionInfo.Attributes         = attributes;
        connectionInfo.Type               = ConnectionInfoType.CRQE;
        connectionInfo.IntegratedSecurity = false;
        TableLogOnInfo tableLogOnInfo = new TableLogOnInfo();

        tableLogOnInfo.ConnectionInfo = connectionInfo;
        return(tableLogOnInfo);
    }
コード例 #2
0
        /// <summary>
        /// We can dynamic change the report provider by this function
        /// </summary>
        /// <param name="serverName"></param>
        /// <param name="databaseName"></param>
        /// <param name="userID"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        private static TableLogOnInfo GetSQLTableLogOnInfo(string serverName, string databaseName, string userID, string password)
        {
            CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag connectionAttributes = new CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag();
            connectionAttributes.EnsureCapacity(11);
            connectionAttributes.Add("Connect Timeout", "15");
            connectionAttributes.Add("Data Source", serverName);
            connectionAttributes.Add("General Timeout", "0");
            connectionAttributes.Add("Initial Catalog", databaseName);
            connectionAttributes.Add("Integrated Security", false);
            connectionAttributes.Add("Locale Identifier", "1033");
            connectionAttributes.Add("OLE DB Services", "-5");
            //connectionAttributes.Add("Provider", "SQLNCLI11");
            connectionAttributes.Add("Provider", "SQLOLEDB");
            connectionAttributes.Add("Tag with column collation when possible", "0");
            connectionAttributes.Add("Use DSN Default Properties", false);
            connectionAttributes.Add("Use Encryption for Data", "0");

            connectionAttributes.Add("Trust Server Certificate", 0);
            connectionAttributes.Add("DataTypeCompatibility", 0);
            connectionAttributes.Add("Auto Translate", -1);
            connectionAttributes.Add("Application Intent", "READWRITE");

            DbConnectionAttributes attributes = new DbConnectionAttributes();

            attributes.Collection.Add(new NameValuePair2("Database DLL", "crdb_ado.dll"));
            attributes.Collection.Add(new NameValuePair2("QE_DatabaseName", databaseName));
            attributes.Collection.Add(new NameValuePair2("QE_DatabaseType", "OLE DB (ADO)"));
            attributes.Collection.Add(new NameValuePair2("QE_LogonProperties", connectionAttributes));
            attributes.Collection.Add(new NameValuePair2("QE_ServerDescription", serverName));
            attributes.Collection.Add(new NameValuePair2("SSO Enabled", false));
            attributes.Collection.Add(new NameValuePair2("QE_SQLDB", true));
            attributes.Collection.Add(new NameValuePair2("Owner", "dbo"));


            CrystalDecisions.Shared.ConnectionInfo connectionInfo = new CrystalDecisions.Shared.ConnectionInfo();
            connectionInfo.Attributes   = attributes;
            connectionInfo.ServerName   = serverName;
            connectionInfo.UserID       = userID;
            connectionInfo.Password     = password;
            connectionInfo.DatabaseName = databaseName;
            connectionInfo.Type         = ConnectionInfoType.SQL;

            TableLogOnInfo tableLogOnInfo = new TableLogOnInfo();

            tableLogOnInfo.ConnectionInfo = connectionInfo;
            return(tableLogOnInfo);
        }
コード例 #3
0
        private NameValuePairs2 GetConnectionAttributes(IConnectionInfo connection)
        {
            string str  = string.Empty;
            string str2 = string.Empty;
            string str3 = string.Empty;
            string str4 = string.Empty;
            string str5 = string.Empty;
            string str6 = string.Empty;
            string str7 = string.Empty;

            foreach (NameValuePair2 pair in connection.Attributes.Collection)
            {
                if (pair.Name.ToString() == "QE_LogonProperties")
                {
                    foreach (NameValuePair2 pair2 in ((DbConnectionAttributes)pair.Value).Collection)
                    {
                        switch (pair2.Name.ToString())
                        {
                        case "Auto Translate":
                            str = pair2.Value.ToString();
                            break;

                        case "Connect Timeout":
                            str2 = pair2.Value.ToString();
                            break;

                        case "General Timeout":
                            str3 = pair2.Value.ToString();
                            break;

                        case "Locale Identifier":
                            str4 = pair2.Value.ToString();
                            break;

                        case "Tag with column collation when possible":
                            str5 = pair2.Value.ToString();
                            break;

                        case "Use DSN Default Properties":
                            str6 = pair2.Value.ToString();
                            break;

                        case "Use Encryption for Data":
                            str7 = pair2.Value.ToString();
                            break;
                        }
                    }
                }
            }
            NameValuePairs2 pairs = new NameValuePairs2();

            pairs.Add(new NameValuePair2("Database DLL", "crdb_ado.dll"));
            pairs.Add(new NameValuePair2("QE_DatabaseName", string.Empty));
            pairs.Add(new NameValuePair2("QE_DatabaseType", "OLE DB (ADO)"));
            DbConnectionAttributes oValue     = new DbConnectionAttributes();
            NameValuePairs2        collection = oValue.Collection;

            collection.Add(!string.IsNullOrEmpty(str) ? new NameValuePair2("Auto Translate", str) : new NameValuePair2("Auto Translate", "-1"));
            collection.Add(!string.IsNullOrEmpty(str2) ? new NameValuePair2("Connect Timeout", str2) : new NameValuePair2("Connect Timeout", "15"));
            collection.Add(new NameValuePair2("Data Source", string.Empty));
            collection.Add(!string.IsNullOrEmpty(str3) ? new NameValuePair2("General Timeout", str3) : new NameValuePair2("General Timeout", "0"));
            collection.Add(new NameValuePair2("Initial Catalog", string.Empty));
            collection.Add(new NameValuePair2("Integrated Security", "FALSE"));
            collection.Add(!string.IsNullOrEmpty(str4) ? new NameValuePair2("Locale Identifier", str4) : new NameValuePair2("Locale Identifier", "1030"));
            collection.Add(new NameValuePair2("OLE DB Services", "-5"));
            collection.Add(new NameValuePair2("Provider", "SQLOLEDB"));
            collection.Add(!string.IsNullOrEmpty(str5) ? new NameValuePair2("Tag with column collation when possible", str5) : new NameValuePair2("Tag with column collation when possible", "0"));
            collection.Add(!string.IsNullOrEmpty(str6) ? new NameValuePair2("Use DSN Default Properties", str6) : new NameValuePair2("Use DSN Default Properties", "false"));
            collection.Add(new NameValuePair2("Use Encryption for Data", "0"));
            collection.Add(!string.IsNullOrEmpty(str7) ? new NameValuePair2("Use Encryption for Data", str7) : new NameValuePair2("Use Encryption for Data", "0"));
            pairs.Add(new NameValuePair2("QE_LogonProperties", oValue));
            pairs.Add(new NameValuePair2("QE_ServerDescription", "."));
            pairs.Add(new NameValuePair2("QE_SQLDB", "true"));
            pairs.Add(new NameValuePair2("SSO Enabled", "false"));
            return(pairs);
        }