Esempio n. 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            DataConnectionDialog dcd = new DataConnectionDialog();
            DataConnectionConfiguration dcs = new DataConnectionConfiguration(null);
            dcs.LoadConfiguration(dcd);

            if (DataConnectionDialog.Show(dcd) == DialogResult.OK)
            {

                textBox2.Text = dcd.ConnectionString;
                connectionString = dcd.ConnectionString;
                comboBox1.Enabled = true;
                using (SqlCeConnection con = new SqlCeConnection(connectionString))
                {
                    comboBox1.Items.Clear();
                    con.Open();
                    using (SqlCeCommand command = new SqlCeCommand("SELECT table_name FROM INFORMATION_SCHEMA.Tables", con))
                    {
                        SqlCeDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            comboBox1.Items.Add(reader.GetString(0));

                        }
                    }
                }
                //textBox1.Text = dcd.SelectedDataSource.DisplayName;
            }
            dcs.SaveConfiguration(dcd);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            DataConnectionDialog dcd = new DataConnectionDialog();
            DataConnectionConfiguration dcs = new DataConnectionConfiguration(null);
            dcs.LoadConfiguration(dcd);

            if (DataConnectionDialog.Show(dcd) == DialogResult.OK)
            {
                // load tables
                using (SqlConnection connection = new SqlConnection(dcd.ConnectionString))
                {
                    connection.Open();
                    SqlCommand cmd = new SqlCommand("SELECT * FROM sys.Tables", connection);

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Console.WriteLine(reader.HasRows);
                        }
                    }

                }
            }

            dcs.SaveConfiguration(dcd);
        }
Esempio n. 3
0
        public string GetConnectionString(string connection)
        {
            string connectionString = connection;

            try
            {
                DataConnectionConfiguration dcs = new DataConnectionConfiguration(null);
                DataConnectionDialog dcd = new DataConnectionDialog();

                //EF CONN STR to SQL CONNECTION
                EntityConnectionStringBuilder efstr = new EntityConnectionStringBuilder(connection);

                dcs.LoadConfiguration(dcd);
                dcd.ConnectionString = efstr.ProviderConnectionString;

                if (DataConnectionDialog.Show(dcd) == System.Windows.Forms.DialogResult.OK)
                {
                    connectionString = dcd.ConnectionString;
                }
                dcs.SaveConfiguration(dcd);

                //SQL CONNECTION TO EF CONN STR
                SqlConnectionStringBuilder sqlstr = new SqlConnectionStringBuilder(dcd.ConnectionString);
                efstr.ProviderConnectionString = sqlstr.ConnectionString;
                connectionString = efstr.ConnectionString;

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return connectionString;
        }
Esempio n. 4
0
        private void btnSqlConnection_Click(object sender, EventArgs e)
        {
            DataConnectionConfiguration dcs = new DataConnectionConfiguration(null); ;

            dcs.LoadConfiguration(dcd);

            if (DataConnectionDialog.Show(dcd) == DialogResult.OK)
            {
                tbDataBaseConnName.Text = dcd.ConnectionString;

            }
        }
		public CommonConnectionStringDialog()
		{
			this._connectionDialog = new DataConnectionDialog();

			this._connectionDialog.DataSources.Add(DataSource.OdbcDataSource);
			this._connectionDialog.DataSources.Add(DataSource.SqlDataSource);
			this._connectionDialog.SelectedDataSource = DataSource.SqlDataSource;

			DataConnectionConfiguration dcs = new DataConnectionConfiguration(null);

			dcs.LoadConfiguration(_connectionDialog);
		}
        // Обработчики сообщений.
        private void connectionsBtn_Click(object sender, EventArgs e)
        {
            DataConnectionDialog connectionDlg = new DataConnectionDialog();
            DataConnectionConfiguration dcs = new DataConnectionConfiguration(null);
            dcs.LoadConfiguration(connectionDlg);

            if (DataConnectionDialog.Show(connectionDlg) == DialogResult.OK)
            {
                this.connectionStringTxt.Text = connectionDlg.ConnectionString;
            }

            dcs.SaveConfiguration(connectionDlg);
            sqlStorage = new SQLResultStorage(new ConnectionStringSettings("temporaryconnection",
                    this.connectionStringTxt.Text, "System.Data.SqlClient"));
        }
        private void AddConnection_Click(object sender, EventArgs e)
        {
            dcd = new DataConnectionDialog();
            DataConnectionConfiguration dcs = new DataConnectionConfiguration(null);
            dcs.LoadConfiguration(dcd);

            if (dcd.SelectedDataProvider != null && dcd.SelectedDataSource != null)
            {
                dcd.ConnectionString = this.textBoxConnStr.Text;
            }
            if (DataConnectionDialog.Show(dcd) == DialogResult.OK)
            {
                textBoxConnStr.Text = dcd.ConnectionString;
            }
            dcs.SaveConfiguration(dcd);
        }
        private void GetConnectionSettings()
        {
            DataConnectionDialog dcd = new DataConnectionDialog();
            DataConnectionConfiguration dcs = new DataConnectionConfiguration(null);
            dcs.LoadConfiguration(dcd);

            if (DataConnectionDialog.Show(dcd) == DialogResult.OK)
            {
                #region set the text boxes according to the connection settings
                if (dcd.SelectedDataSource != null)
                {
                    if (dcd.SelectedDataSource == dcd.UnspecifiedDataSource)
                    {
                        if (dcd.SelectedDataProvider != null)
                        {
                            m_GuiDbProviderTextBox.Text = dcd.SelectedDataProvider.DisplayName;
                        }
                        else
                        {
                            m_GuiDbProviderTextBox.Text = null;
                        }
                    }
                    else
                    {
                        m_GuiDbProviderTextBox.Text = dcd.SelectedDataSource.DisplayName;
                        if (dcd.SelectedDataProvider != null)
                        {
                            if (dcd.SelectedDataProvider.ShortDisplayName != null)
                            {
                                m_GuiDbProviderTextBox.Text = String.Format("{0} ({1})", m_GuiDbProviderTextBox.Text, dcd.SelectedDataProvider.ShortDisplayName);
                            }
                        }
                    }
                }
                else
                {
                    m_GuiDbProviderTextBox.Text = null;
                }

                m_GuiConnectionStringTextBox.Text = dcd.ConnectionString;

                ChangeStateToDirty();
                #endregion
            }
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            DataConnectionDialog dcd = new DataConnectionDialog();
            DataConnectionConfiguration dcs = new DataConnectionConfiguration(null);
            dcs.LoadConfiguration(dcd);

            if (DataConnectionDialog.Show(dcd) == DialogResult.OK)
            {
                DbProviderFactory factory = DbProviderFactories.GetFactory(dcd.SelectedDataProvider.Name);
                using (var connection = factory.CreateConnection())
                {
                    connection.ConnectionString = dcd.ConnectionString;
                    connection.Open();
                    var command = connection.CreateCommand();
                    command.CommandType = CommandType.Text;
                    command.CommandText = "SELECT * FROM INFORMATION_SCHEMA.TABLES";
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Console.WriteLine(reader["name"]);
                        }
                    }
                }

                // load tables
                //using (SqlConnection connection = new SqlConnection(dcd.ConnectionString))
                //{
                //    connection.Open();
                //    SqlCommand cmd = new SqlCommand("SELECT * FROM sys.Tables", connection);

                //    using (SqlDataReader reader = cmd.ExecuteReader())
                //    {
                //        while (reader.Read())
                //        {
                //            Console.WriteLine(reader.HasRows);
                //        }
                //    }

                //}
            }

            dcs.SaveConfiguration(dcd);
        }
        private void frmGenerate_Load(object sender, EventArgs e)
        {
            // Load previous settings
            if (!string.IsNullOrEmpty(Properties.Settings.Default.LastDropFolder))
            {
                this.txtFolder.Text = Properties.Settings.Default.LastDropFolder;
            }
            this.chkCreateIndex.Checked = Properties.Settings.Default.LastIndexChoice;

            DataConnectionDialog dcd = new DataConnectionDialog();
            DataConnectionConfiguration dcs = new DataConnectionConfiguration(null);
            dcs.LoadConfiguration(dcd);

            if (DataConnectionDialog.Show(dcd) == DialogResult.OK)
            {

                Globals.ConnectionString = dcd.ConnectionString;

                // Populate the table list
                LoadTableList();
            }
            else
            {
                this.Close();
            }
        }
		private DataConnectionDialog GetDataConnectionDialog()
		{
			DataConnectionDialog connectionDialog = new DataConnectionDialog();

			connectionDialog.DataSources.Add(DataSource.OdbcDataSource);
			connectionDialog.DataSources.Add(DataSource.SqlDataSource);
			connectionDialog.SelectedDataSource = DataSource.SqlDataSource;

			DataConnectionConfiguration dcs = new DataConnectionConfiguration(null);

			dcs.LoadConfiguration(connectionDialog);

			return connectionDialog;
		}
        private void sqlConnection_Click(object sender, EventArgs e)
        {
            dcd = new DataConnectionDialog();
            DataConnectionConfiguration dcs = new DataConnectionConfiguration(null);
            dcs.LoadConfiguration(dcd);

            if (DataConnectionDialog.Show(dcd) == DialogResult.OK)
            {
                switch (this.mainTab.SelectedIndex)
                {
                    case 0:
                        {
                            this.sqlStorageConnTxt.Text = dcd.ConnectionString;
                            break;
                        }
                    case 1:
                        {
                            this.connectionStringTxt.Text = dcd.ConnectionString;
                            break;
                        }
                    default:
                        {
                            break;
                        }
                }
            }

            dcs.SaveConfiguration(dcd);
        }
Esempio n. 13
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                DataConnectionDialog dcd = new DataConnectionDialog();
                DataConnectionConfiguration dcs = new DataConnectionConfiguration(null);
                dcs.LoadConfiguration(dcd);

                if (DataConnectionDialog.Show(dcd) == DialogResult.OK)
                {
                    SaveConnString(dcd.ConnectionString);
                    // load tables
                    //using (SqlConnection connection = new SqlConnection(dcd.ConnectionString))
                    //{
                    //    connection.Open();
                    //    SqlCommand cmd = new SqlCommand("SELECT * FROM sys.Tables", connection);

                    //    using (SqlDataReader reader = cmd.ExecuteReader())
                    //    {
                    //        while (reader.Read())
                    //        {

                    //            Console.WriteLine(reader.HasRows);
                    //        }
                    //    }

                    //}
                }

                dcs.SaveConfiguration(dcd);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                //    string winpath = Environment.ExpandEnvironmentVariables("%SystemRoot%");
                //    File.Copy("sqlcese35.dll", winpath + @"\sqlcese35.dll");
                //    File.Copy("sqlceqp35.dll", winpath + @"\sqlceqp35.dll");
                //    File.Copy("sqlceme35.dll", winpath + @"\sqlceme35.dll");
                //    MessageBox.Show("sqlce导入成功");
            }
        }
 /// <summary>
 /// Method that call DataConnectionDialog 
 /// </summary>
 /// <returns>string of configured connection</returns>
 private string getConnectionString()
 {
     string connString = null;
     DataConnectionDialog dcd = new DataConnectionDialog();
     DataConnectionConfiguration dcs = new DataConnectionConfiguration(null);
     dcs.LoadConfiguration(dcd);
     if (DataConnectionDialog.Show(dcd) == System.Windows.Forms.DialogResult.OK)
         connString = dcd.ConnectionString;
     dcs.SaveConfiguration(dcd);
     return connString;
 }