コード例 #1
0
		private void selectSqlConnection(string connectionString, DBType dbType, string connectionName, bool isODBC)
		{
			if (!this.cbConnection.Items.OfType<LastDirectConnectionString>().Any(
				x => x.ConnectionString == connectionString
				&& x.IsODBC == isODBC
				)
			)
			{
				LastDirectConnectionString newItem = new LastDirectConnectionString()
				{
					DataBaseType     = dbType.Id.ToString(),
					ConnectionString = connectionString,
					IsODBC           = isODBC,
					Name             = connectionName
				};

				this.cbConnection.Items.Add(newItem);
				this.cbConnection.SelectedItem = newItem;
			}
			else
			{
				LastDirectConnectionString item =
					this.cbConnection.Items.OfType<LastDirectConnectionString>()
						.First(x => x.ConnectionString == connectionString && x.IsODBC == isODBC);

				this.cbConnection.SelectedItem = item;
			}
		}
コード例 #2
0
		private static DbConnectionStringBuilder GetConnectionStringBuilder(LastDirectConnectionString connectionString)
		{
			if (connectionString.IsODBC)
			{
				return new OdbcConnectionStringBuilder(connectionString.ConnectionString);
			}

			DbConnectionStringBuilder builder;
			QuerySource               dbType;

			if (Enum.TryParse(connectionString.DataBaseType, out dbType))
			{
				switch (dbType)
				{
					case QuerySource.MSSQL:
						builder = new SqlConnectionStringBuilder();
						break;
					case QuerySource.SQLite:
						// ODBC connection string builder is used
						// for SQLite internal connection
						// since it handles special connection string adequately
						builder = new OdbcConnectionStringBuilder();
						break;
					default:
						builder = new DbConnectionStringBuilder();
						break;
				}
			}
			else
			{
				builder = new DbConnectionStringBuilder();
			}

			builder.ConnectionString = connectionString.ConnectionString;
			return builder;
		}