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); }
/// <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); }