Inheritance: IDictionary, ICollection, IEnumerable
        public string GetConnectionString(AbstractConnection connection) {

            if (string.IsNullOrEmpty(ServerProperty))
                return string.Empty;

            var builder = new DbConnectionStringBuilder { { ServerProperty, connection.Server } };

            if (!string.IsNullOrEmpty(connection.Database)) {
                builder.Add(DatabaseProperty, connection.Database);
            }

            if (!String.IsNullOrEmpty(connection.User)) {
                builder.Add(UserProperty, connection.User);
                builder.Add(PasswordProperty, connection.Password);
            } else {
                if (!String.IsNullOrEmpty(TrustedProperty)) {
                    builder.Add(TrustedProperty, true);
                }
            }

            if (PersistSecurityInfoProperty != string.Empty && connection.PersistSecurityInfo != string.Empty) {
                builder.Add(PersistSecurityInfoProperty, connection.PersistSecurityInfo);
            }

            if (connection.Port <= 0)
                return builder.ConnectionString;

            if (PortProperty == string.Empty) {
                builder[ServerProperty] += "," + connection.Port;
            } else {
                builder.Add("Port", connection.Port);
            }
            return builder.ConnectionString;
        }
Ejemplo n.º 2
0
        public void Test()
        {
            try
            {
                var connectionString = new DbConnectionStringBuilder();
                connectionString["Data Source"] = "ANNE\\OJB_NET";
                connectionString["Initial Catalog"] = "unittest";
                connectionString["Integrated Security"] = "SSPI";
                connectionString["MultipleActiveResultSets"] = true;
                var connection = new SqlConnection(connectionString.ConnectionString);

                var context = new Context {Connection = connection, IsSqlCeConnectionBug = true};
                context.UpdateDatabase();

                var address = new Address {Id = 1, Text = "5th Ave, City23"};
                var customer = new Customer {Id = 1, Name = "Cust co ldt.", Address = address};
                context.Container.Address.Add(address);
                context.Container.Customer.Add(customer);
                //context.SaveChanges();
                var customers = context.Container.Customer.Where(c => c.Id == 1).Where(c => c.Id == 1);
                var customersFound = customers.ToArray();
                var customerFound = customers.Single();
            }
            catch(Exception)
            {
                Debugger.Break();
                throw;
            }
        }
		public static InstanceInfo ResolveInstance(
			DbConnectionStringBuilder builder,
			bool                      isOdbc,
			QuerySource               dbType
		)
		{
			InstanceInfo instance;

			if (dbType == QuerySource.SQLite || dbType == QuerySource.NetworkInformation)
			{
				instance = ResolveNonDatabase(
					builder.ConnectionString,
					dbType
				);
			}
			else
			{
				instance = ResolveDatabase(
					builder,
					dbType,
					isOdbc
				);
			}

			return instance;
		}
Ejemplo n.º 4
0
        public string GetDataBaseName(System.Data.Common.DbConnectionStringBuilder builder)
        {
            object database = "";

            builder.TryGetValue("database", out database);
            if (database == null || string.IsNullOrEmpty(database.ToString()))
            {
                builder.TryGetValue("initial catalog", out database);
            }
            if (database == null || string.IsNullOrEmpty(database.ToString()))
            {
                builder.TryGetValue("data source", out database);
                if (database != null)
                {
                    if (database.ToString().Contains("/"))
                    {
                        return(database.ToString().Split('/')[1]);
                    }
                }
            }
            if (database == null || string.IsNullOrEmpty(database.ToString()))
            {
                throw new Exception(ProviderName + " must have database;" + builder.ConnectionString);
            }
            return(database.ToString().FirstLetterToUpper());
        }
        IConnectionStringProvider CreateConfigPerEndpointConnectionStringProvider(LocalConnectionParams localConnectionParams)
        {
            const string transportConnectionStringPrefix = "NServiceBus/Transport/";
            var configConnectionStrings =
                connectionStrings
                    .Where(x => x.Name.StartsWith(transportConnectionStringPrefix))
                    .Select(x =>
                    {
                        string schema;
                        var connectionString = x.ConnectionString.ExtractSchemaName(out schema);
                        var endpoint = x.Name.Replace(transportConnectionStringPrefix, String.Empty);
                        var connectionInfo = EndpointConnectionInfo.For(endpoint).UseSchema(schema);

                        var localConnectionStringBuilder = new DbConnectionStringBuilder { ConnectionString = localConnectionParams.ConnectionString };
                        var overriddenConnectionStringBuilder = new DbConnectionStringBuilder { ConnectionString = connectionString };

                        if (!localConnectionStringBuilder.EquivalentTo(overriddenConnectionStringBuilder))
                        {
                            connectionInfo = connectionInfo.UseConnectionString(connectionString);
                        }
                        return connectionInfo;
                    })
                    .ToArray();

            return new CollectionConnectionStringProvider(configConnectionStrings, localConnectionParams);
        }
 public NpgsqlMetadataReader(string connectionStr)
 {
     this._connectionString = connectionStr;
     DbConnectionStringBuilder connStr = new DbConnectionStringBuilder();
     connStr.ConnectionString = _connectionString;
     DatabaseName = connStr["Database"] as String;
 }
Ejemplo n.º 7
0
        protected DbProvider(string connectionString, System.Data.Common.DbProviderFactory dbProviderFactory)
        {
            this.dbConnectionStringBuilder = new DbConnectionStringBuilder();
            this.dbConnectionStringBuilder.ConnectionString = connectionString;
            this.dbProviderFactory = dbProviderFactory;

        }
        //TODO: Custom config section?
        //TODO: Combine constructors
        public DomainCredential(string connectionString)
        {
            //TODO: Custom parser?
            var builder = new DbConnectionStringBuilder();
            builder.ConnectionString = connectionString;

            object[] value = new object[6];
            builder.TryGetValue("NetBIOS", out value[0]);
            builder.TryGetValue("Domain", out value[1]);
            builder.TryGetValue("Container", out value[2]);
            builder.TryGetValue("Username", out value[3]);
            builder.TryGetValue("Password", out value[4]);
            builder.TryGetValue("SecureConnection", out value[5]);

            if (String.IsNullOrWhiteSpace(value[0] as string))
                throw new ArgumentNullException("netbios");
            if (String.IsNullOrWhiteSpace(value[1] as string))
                throw new ArgumentNullException("domain");
            if (String.IsNullOrWhiteSpace(value[2] as string))
                throw new ArgumentNullException("container");

            NetBIOS = value[0] as string;
            Domain = value[1] as string;
            Container = value[2] as string;
            Username = value[3] as string;
            Password = value[4] as string;
            SecureConnection = bool.Parse(value[5] as string ?? "False");
        }
        private static void EnsureDatabase()
        {
            using (var connection = SqlConnections.NewByKey("Default"))
                try
                {
                    connection.Open();
                }
                catch
                {
                    var cb = new DbConnectionStringBuilder();
                    cb.ConnectionString = SqlConnections.GetConnectionString("Default").ConnectionString;
                    var catalog = cb["Initial Catalog"];
                    cb["Initial Catalog"] = null;
                    cb["AttachDBFilename"] = null;

                    using (var serverConnection = new SqlConnection(cb.ConnectionString))
                    {
                        serverConnection.Open();
                        serverConnection.Execute(String.Format(
                            @"CREATE DATABASE [{0}] ON PRIMARY (Name = N'{0}', FILENAME = '{1}\{0}.mdf') LOG ON (NAME = N'{0}_log', FILENAME = '{1}\{0}.ldf');",
                                catalog, HostingEnvironment.MapPath("~/App_Data")));
                    }

                    SqlConnection.ClearAllPools();
                }

            RunMigrations();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// This function returns login and password of user for a passed NpgsqlConnection
        /// </summary>
        /// <param name="connection">the current opened DbConnection</param>
        /// <param name="login">returned login corresponding to the NpgsqlConnection passed</param>
        /// <param name="password">returned password corresponding to the NpgsqlConnection passed</param>
        /// <returns>true if succeed, false otherwise (connection null or not opened)</returns>
        public static bool GetConnectionInformationsFrom(
                                      IDbConnection connection,
                                      out string login,
                                      out string password)
        {
            login = string.Empty;
            password = string.Empty;

            if ((connection != null) && (connection.State == System.Data.ConnectionState.Open))
            {
                DbConnectionStringBuilder builder = new DbConnectionStringBuilder();
                builder.ConnectionString = connection.ConnectionString;

                if (builder != null)
                {
                    object value = null;
                    bool result = builder.TryGetValue("User Id", out value);
                    if (result)
                    {
                        login = value.ToString();
                    }

                    result &= builder.TryGetValue("Password", out value);
                    if (result)
                    {
                        password = value.ToString();
                    }

                    builder.Clear();
                    return result;
                }
            }

            return false;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Replaces any existing 'enlist' parameter in the connection string
        /// with a value indicating that manual enlist is necessary.
        /// </summary>
        /// <remarks>
        /// ODP.NET supports 3 values for 'enlist'; 'true', 'false' and 'dynamic'.
        ///  'dynamic' effectively works the same as 'false' in System.Data.OracleClient.
        /// </remarks>
        protected override void ReplaceEnlistInConnectionString(DbConnectionStringBuilder dbConnectionStringBuilder)
        {
            if (dbConnectionStringBuilder.ContainsKey("enlist"))
                dbConnectionStringBuilder.Remove("enlist");

            dbConnectionStringBuilder.Add("enlist", "dynamic");
        }
 public ConnectionStringBuilder(GenDatabase db)
 {
     GenDatabase = db;
     DbConnectionStringBuilder = GenDatabase.DbProviderFactory.CreateConnectionStringBuilder();
     if (db.GenProviderType == GenProviderType.OleDb)
         ((OleDbConnectionStringBuilder)DbConnectionStringBuilder).Provider = GenDatabase.OleDbName;
 }
Ejemplo n.º 13
0
        private void instancesComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            string server = (string)instancesComboBox.SelectedItem;

             DbConnectionStringBuilder builder = new DbConnectionStringBuilder();
             builder.Add("Data Source", server);
             builder.Add("Initial Catalog", "master");
             builder.Add("Integrated Security", "SSPI");

             using ( SqlConnection conn = new SqlConnection(builder.ConnectionString) )
             {
            SqlCommand cmd = new SqlCommand("select name from sys.databases", conn);
            conn.Open();

            using ( SqlDataReader reader = cmd.ExecuteReader() )
            {
               List<string> dbs = new List<string>();
               while ( reader.Read() )
               {
                  dbs.Add(reader.GetString(0));
               }
               dbsComboBox.DataSource = dbs;
            }
             }
        }
Ejemplo n.º 14
0
 public BaseNode(string text, DbConnectionStringBuilder builder,DataType nodetype)
     : base(text)
 {
     this.ConnectionStringBuilder = builder;
     this.datatype = nodetype;
     this.Nodes.Add(new DummyNode());
 }
Ejemplo n.º 15
0
        static void Main()
        {
            DbConnectionStringBuilder dcsBuilder = new DbConnectionStringBuilder();
            dcsBuilder.Add("User ID", "wjzgis");
            dcsBuilder.Add("Password", "wjzgis");
            dcsBuilder.Add("Service Name", "sunz");
            dcsBuilder.Add("Host", "172.16.1.9");
            dcsBuilder.Add("Integrated Security", false);
            string licPath = Application.StartupPath + "\\DDTek.lic";
            //dcsBuilder.Add("License Path", licPath);
            //若路径中存在空格,则会在路径名称前加上"\""
            string conStr = dcsBuilder.ConnectionString;
            conStr = conStr.Replace("\"", "");

            Configuration config = new Configuration();
            config.AddDirectory(new System.IO.DirectoryInfo( System.IO.Path.Combine(Application.StartupPath, "DataMapping")));

            config.Properties["connection.connection_string"] = conStr;

            NHibernate.ISessionFactory sFactory = config.BuildSessionFactory();
            NHibernate.ISession session = sFactory.OpenSession();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
        protected void CheckAssertions(string connectionString)
        {
            DbConnectionStringBuilder dbConnection = new DbConnectionStringBuilder { ConnectionString = connectionString };

            foreach (ConnectionStringSetting setting in StringSettings)
            {
                if (dbConnection.ContainsKey(setting.SettingName))
                {
                    AssertState.Equal(setting.ExpectedValue, dbConnection[setting.SettingName].ToString());
                }
                else
                {
                    throw new AssertionException(string.Format("Connection String setting [{0}] not found", setting.SettingName));
                }
            }

            if (dbConnection.Keys != null)
                AssertState.Equal(StringSettings.Count, dbConnection.Keys.Count);
            else
            {
                throw new AssertionException("No StringSetting values were found");
            }

            if (CheckConnectivity)
                using (SqlConnection sqlConnection = (new SqlConnection(connectionString)))
                    sqlConnection.Open();
        }
 public IngresMetadataReader(string connectionStr)
 {
     _connectionString = connectionStr;
     DbConnectionStringBuilder connStr = new DbConnectionStringBuilder();
     connStr.ConnectionString = _connectionString;
     DatabaseName = connStr["Database"] as String;
 }
        public Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            string connectionStringName = config.Properties["ConnectionStringName"];

            if (string.IsNullOrEmpty(connectionStringName))
            {
                this.Log.Info("Starting RavenDB Storage Provider InMemory");
                return this.InMemoryMode();
            }

            var settings = ConfigurationManager.ConnectionStrings[connectionStringName];

            var connectionStringBuilder = new DbConnectionStringBuilder
            {
                ConnectionString = settings.ConnectionString
            };

            object url;
            if (connectionStringBuilder.TryGetValue("Url", out url))
            {
                this.Log.Info("Starting RavenDB Storage Provider attached to server {0}", url);
                return this.ServerMode(connectionStringName);
            }

            object dataDir;
            if (connectionStringBuilder.TryGetValue("DataDir", out dataDir))
            {
                this.Log.Info("Starting RavenDB Storage Provider embedded in directory {0}", dataDir);
                return this.LocalMode(connectionStringName);
            }

            return TaskDone.Done;
        }
Ejemplo n.º 19
0
        public static string GetConnectionString()
        {
            System.Data.Common.DbConnectionStringBuilder sb= new DbConnectionStringBuilder();
            sb.ConnectionString = ConfigurationManager.ConnectionStrings["trackDBEntities2"].ConnectionString;

            return sb["provider connection string"].ToString();
        }
 /// <summary>
 /// Gets the provider information stored on the connection string
 /// </summary>
 /// <param name="connection">The connection object to get the connection string from</param>
 /// <returns>An string providing the provider information</returns>
 public static String GetConnectionProvider(DbConnection connection)
 {
     object result = String.Empty;
     DbConnectionStringBuilder builder = new DbConnectionStringBuilder();
     builder.ConnectionString = connection.ConnectionString;
     builder.TryGetValue("Provider", out result);
     return result == null ? string.Empty : (string)result;
 }
Ejemplo n.º 21
0
    public ConnectionStringEditorDlg()
    {
      InitializeComponent();

      DbProviderFactory factory = DbProviderFactories.GetFactory("MySql.Data.MySqlClient");
      builder = factory.CreateConnectionStringBuilder();
      connStrProps.SelectedObject = builder;
    }
Ejemplo n.º 22
0
        public IDbDriver CreateDatabaseObject(System.Data.Common.DbConnectionStringBuilder connectionStringBuilder)
        {
            IDbDriver instance = new EpiWebDataSource();

            instance.ConnectionString = connectionStringBuilder.ConnectionString;

            return(instance);
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:DbProvider"/> class.
 /// </summary>
 /// <param name="connectionString">The conn STR.</param>
 /// <param name="dbProviderFactory">The db provider factory.</param>
 /// <param name="leftToken">leftToken</param>
 /// <param name="paramPrefixToken">paramPrefixToken</param>
 /// <param name="rightToken">rightToken</param>
 protected DbProvider(string connectionString, DbProviderFactory dbProviderFactory, char leftToken, char rightToken, char paramPrefixToken)
 {
     dbConnStrBuilder = new DbConnectionStringBuilder();
     dbConnStrBuilder.ConnectionString = connectionString;
     this.dbProviderFactory = dbProviderFactory;
     this.leftToken = leftToken;
     this.rightToken = rightToken;
     this.paramPrefixToken = paramPrefixToken;
 }
Ejemplo n.º 24
0
 public ConnectDialog()
 {
   InitializeComponent();
   factory = DbProviderFactories.GetFactory("MySql.Data.MySqlClient");
   if (factory == null)
     throw new Exception("MySql Data Provider is not correctly registered");
   connectionStringBuilder = factory.CreateConnectionStringBuilder();
   connectionProperties.SelectedObject = connectionStringBuilder;
 }
 private static string GetDataSourceFilePath(DbConnectionStringBuilder builder, string connectionString)
 {
     builder.ConnectionString = connectionString;
     if (!builder.ContainsKey("Data Source"))
     {
         throw new ArgumentException("A 'Data Source' parameter was expected in the supplied connection string, but it was not found.");
     }
     return ConnectionStringHelper.ResolveDataSourceFilePath(builder["Data Source"].ToString());
 }
Ejemplo n.º 26
0
 public void Initialize(string connectionString)
 {
     var parser = new DbConnectionStringBuilder {ConnectionString = connectionString};
     var fileName = parser.ContainsKey("Filename")
         ? parser["Filename"].ToString()
         : Path.Combine(Directory.GetCurrentDirectory(), "PlayPass.log");
     var appendMode = !parser.ContainsKey("Append") || (parser["Append"].ToString() == "1");
     _file = new StreamWriter(fileName, appendMode) {AutoFlush = true};
 }
Ejemplo n.º 27
0
        public DataAccess(DataProvider dataProvider, string connectionString)
        {
            if (!Enum.IsDefined(typeof(DataProvider), dataProvider))
                throw new ArgumentException(Resources.DataAccessInvalidDataProvider, "dataProvider");

            this.dataProvider = dataProvider;
            this.dbConnectionStringBuilder = DataAccessBuilder.CreateConnectionStringBuilder(dataProvider);
            this.dbConnectionStringBuilder.ConnectionString = connectionString;
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:MockConnection"/> class.
 /// </summary>
 /// <param name="connectionString">The connection string to use.</param>
 /// <param name="useOdbcRules"><c>true</c> to use {} to delimit fields; <c>false</c> to use quotation marks.</param>
 public MockConnection(String connectionString, Boolean useOdbcRules)
     : base()
 {
     DbConnectionStringBuilder connectionStringBuilder = new DbConnectionStringBuilder(useOdbcRules);
     if (connectionString != null) {
         connectionStringBuilder.ConnectionString = connectionString;
     }
     this._connectionStringBuilder = connectionStringBuilder;
 }
Ejemplo n.º 29
0
        public DynamicModel(DbConnectionStringBuilder connectionStringBuilder, string tableName = "", string primaryKeyField = "")
        {
            TableName = tableName == "" ? this.GetType().Name : tableName;
            PrimaryKeyField = string.IsNullOrEmpty(primaryKeyField) ? "ID" : primaryKeyField;

            _factory = DbProviderFactories.GetFactory("System.Data.SQLite");

            ConnectionString = connectionStringBuilder.ConnectionString;
        }
Ejemplo n.º 30
0
 private static string getConnString( string userID, string password, string dataSource, string initialCatalog )
 {
     DbConnectionStringBuilder builder = new DbConnectionStringBuilder ();
     builder [ "Data Source" ] = dataSource;
     builder [ "Initial Catalog" ] = initialCatalog;
     builder [ "User Id" ] = userID;
     builder [ "Password" ] = password;
     return builder.ConnectionString;
 }
Ejemplo n.º 31
0
        public Form1()
        {
            InitializeComponent();

            DataTable dtProviderFactorys = DbProviderFactories.GetFactoryClasses();

            DbConnectionStringBuilder dcsBuilder = new DbConnectionStringBuilder();
            dcsBuilder.Add("User ID", "hzzgis");
            dcsBuilder.Add("Password", "hzzgis");
            dcsBuilder.Add("Service Name", "sunz");
            dcsBuilder.Add("Host", "172.16.1.9");
            dcsBuilder.Add("Integrated Security", false);

            string licPath = Application.StartupPath + "\\DDTek.lic";
            if (!System.IO.File.Exists(licPath))
                licPath = CretateDDTekLic.CreateLic();
            dcsBuilder.Add("License Path", licPath);
            //若路径中存在空格,则会在路径名称前加上"\""
            string conStr = dcsBuilder.ConnectionString;
            conStr = conStr.Replace("\"", "");

            DDTek.Oracle.OracleConnection orclConnection = new DDTek.Oracle.OracleConnection(conStr);

            DDTek.Oracle.OracleCommand cmd = new DDTek.Oracle.OracleCommand();
            DDTek.Oracle.OracleDataAdapter adapter = new DDTek.Oracle.OracleDataAdapter();
            adapter.SelectCommand = cmd;
            DbDataAdapter dAdapter = adapter;
            DbCommand dbCommand = dAdapter.SelectCommand;

            orclConnection.Open();

            //Configuration config = new Configuration();

            //ISessionFactory pFactory = config.BuildSessionFactory();
            //ISession pSession= pFactory.OpenSession(orclConnection as IDbConnection);

            //DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OracleClient");
            //IDbConnection dbConn = factory.CreateConnection();
            //if (dbConn != null)
            //    MessageBox.Show("Connection Created");
            //Conn.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + Server + ")(PORT=" + Port + ")))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" + Service + ")));user id=" + User + ";password="******";pooling = true;Unicode=True";

            IDbConnection dbConn=new System.Data.OleDb.OleDbConnection();
            string Server = "sunzvm-lc", Port = "1521", Service = "sunz", User = "******", PWD = "hzzgis";
            //dbConn.ConnectionString = "Provider=OraOLEDB.Oracle.1;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + Server + ")(PORT=" + Port + ")))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" + Service + ")));user id=" + User + ";password="******";pooling = true;Unicode=True";
            dbConn.ConnectionString = "Provider=MSDAORA.1;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + Server + ")(PORT=" + Port + ")))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" + Service + ")));user id=" + User + ";password="******";pooling = true;Unicode=True";

            try
            {
                dbConn.Open();
            }
            catch(Exception exp)
            {
                MessageBox.Show(exp.ToString());
            }
        }
Ejemplo n.º 32
0
        public string GetDataBaseName(System.Data.Common.DbConnectionStringBuilder builder)
        {
            object database = "";

            builder.TryGetValue("Data Source", out database);
            if (database == null || string.IsNullOrEmpty(database.ToString()))
            {
                throw new Exception(ProviderName + " Data Source error!");
            }
            database = Path.GetFileName(database.ToString()).Replace(".db", "");
            return(database.ToString());
        }
Ejemplo n.º 33
0
        internal static string GetDatabaseName(System.Data.Common.DbConnectionStringBuilder connectionStringBuilder)
        {
            object objDbName;
            string dbName = null;

            if (connectionStringBuilder.TryGetValue("USER ID", out objDbName))
            {
                dbName = objDbName.ToString();
            }
            else if (connectionStringBuilder.TryGetValue("UID", out objDbName))
            {
                dbName = objDbName.ToString();
            }
            return(dbName.ToUpper());
        }
Ejemplo n.º 34
0
        public string GetDataBaseName(System.Data.Common.DbConnectionStringBuilder builder)
        {
            object database = "";

            builder.TryGetValue("database", out database);
            if (database == null || string.IsNullOrEmpty(database.ToString()))
            {
                builder.TryGetValue("initial catalog", out database);
            }
            if (database == null || string.IsNullOrEmpty(database.ToString()))
            {
                throw new Exception(ProviderName + " must have database;" + builder.ConnectionString);
            }
            return(database.ToString());
        }
        public override bool ShouldSerializeValue(object component)
        {
            DbConnectionStringBuilder builder = component as DbConnectionStringBuilder;

            return((builder != null) && builder.ShouldSerialize(this.DisplayName));
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (Request.QueryString["Param"] != null)
        //{

        if (Session["order_id"] != "")
        {
            Order_Id = Session["order_id"].ToString();
            Template = Session["Template"].ToString();
        }
        // Order_Id = Request.QueryString["Param"].ToString();

        System.Data.Common.DbConnectionStringBuilder builder = new System.Data.Common.DbConnectionStringBuilder();
        builder.ConnectionString = ConfigurationManager.ConnectionStrings["TaxManagementConnectionString"].ConnectionString;
        string server   = builder["Data Source"] as string;
        string database = builder["Initial Catalog"] as string;
        string UserID   = builder["User ID"] as string;
        string password = builder["Password"] as string;
        //int OrderID = int.Parse(Session["OrderID"].ToString());
        //int ClintID = int.Parse(Session["ClientID"].ToString());
        // string LetterCase = Convert.ToString(Session["CaseLetter"].ToString());
        //int SubProcessID = int.Parse(Session["SubProcessID"].ToString());
        // string Trans = "OrderWise";

        //int ProcessID=1;

        TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
        TableLogOnInfo  crtableLogoninfo  = new TableLogOnInfo();
        ConnectionInfo  crConnectionInfo  = new ConnectionInfo();
        Tables          CrTables;

        if (Template == "Template1")
        {
            rptDoc.Load(Server.MapPath("~/Reports/Clients/GLS/Rpt_Tax_Information_Client_Granit.rpt"));
        }
        else if (Template == "Template2")
        {
            rptDoc.Load(Server.MapPath("~/Reports/Clients/GLS/Rpt_Tax_Information_Client_Granit_Temp2.rpt"));
        }

        // Order_Details_Page_1 Parameterhttp:
        rptDoc.SetParameterValue("@Order_ID", Order_Id);
        rptDoc.SetParameterValue("@Order_ID", Order_Id, "Notes");

        crConnectionInfo.ServerName   = server;
        crConnectionInfo.DatabaseName = database;
        crConnectionInfo.UserID       = UserID;
        crConnectionInfo.Password     = password;
        CrTables = rptDoc.Database.Tables;
        foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
        {
            crtableLogoninfo = CrTable.LogOnInfo;
            crtableLogoninfo.ConnectionInfo = crConnectionInfo;
            CrTable.ApplyLogOnInfo(crtableLogoninfo);
        }

        foreach (ReportDocument sr in rptDoc.Subreports)
        {
            foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in sr.Database.Tables)
            {
                crtableLogoninfo = CrTable.LogOnInfo;
                crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                CrTable.ApplyLogOnInfo(crtableLogoninfo);
            }
        }

        Session["rptDoc"] = rptDoc;
        rptDoc.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath("~/Reports/Clients/GLS/Rpt_Tax_Information_Client_Granit.pdf"));
        // CrystalReportViewer1.ReportSource = rptDoc;
        MemoryStream oStream = default(MemoryStream);

        oStream = (MemoryStream)rptDoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
        Response.Clear();
        Response.Buffer      = true;
        Response.ContentType = "application/pdf";
        Response.BinaryWrite(oStream.ToArray());
        Response.End();
        //RadPdfTableTruncate();
        //PdfView();


        // }
    }
 public virtual bool EquivalentTo(DbConnectionStringBuilder connectionStringBuilder)
 {
     return(false);
 }
Ejemplo n.º 38
0
 public static string Provider(this DbConnectionStringBuilder csb) => (string)csb[nameof(Provider)];
Ejemplo n.º 39
0
 protected DbProvider(string connectionString, System.Data.Common.DbProviderFactory dbProviderFactory)
 {
     this.dbConnectionStringBuilder = new DbConnectionStringBuilder();
     this.dbConnectionStringBuilder.ConnectionString = connectionString;
     this.dbProviderFactory = dbProviderFactory;
 }
Ejemplo n.º 40
0
        public override bool CanResetValue(object component)
        {
            DbConnectionStringBuilder builder = (component as DbConnectionStringBuilder);

            return((null != builder) && builder.ShouldSerialize(DisplayName));
        }
Ejemplo n.º 41
0
 public static string DataSource(this DbConnectionStringBuilder csb) => (string)csb["Data Source"];
Ejemplo n.º 42
-1
			public DBParam(DBConnectInfo.DBType dbType, PropertyInfo prop, DbConnectionStringBuilder values, DbConnectionStringBuilder defaults)
			{
				DBType = dbType;
				Name = prop.Name;
				try { Original = prop.GetValue(values); } catch { }
				try { Default = prop.GetValue(defaults); } catch { }
				Value = Original;
				Type = prop.PropertyType;
			}