private DataSource GetDataSourceFromDataProvider(DataProvider p)
 {
     if (p == Microsoft.Data.ConnectionUI.DataProvider.SqlDataProvider)
         return Microsoft.Data.ConnectionUI.DataSource.SqlDataSource;
     else if (p == Microsoft.Data.ConnectionUI.DataProvider.OdbcDataProvider)
         return Microsoft.Data.ConnectionUI.DataSource.OdbcDataSource;
     else if (p == Microsoft.Data.ConnectionUI.DataProvider.OleDBDataProvider)
         return Microsoft.Data.ConnectionUI.DataSource.OdbcDataSource;
     else if (p == Microsoft.Data.ConnectionUI.DataProvider.OracleDataProvider)
         return Microsoft.Data.ConnectionUI.DataSource.OracleDataSource;
     else
         return null;
 }
Esempio n. 2
0
        public string Change(string connString = "")
        {
            string tempConnString = !string.IsNullOrEmpty(connString) ? connString : this.ConnString;
            try
            {
                if (string.IsNullOrEmpty(tempConnString))
                    return this.GetConnString();
                if (tempConnString.Equals(this.Dialog.ConnectionString))
                    return this.GetConnString();

                if (tempConnString.ToLower().Contains("provider"))
                {
                    if (tempConnString.ToLower().Contains("msdaora"))
                    {
                        this.DataSource = DataSource.OracleDataSource;
                    }
                    else
                    {
                        this.DataSource = DataSource.SqlDataSource;
                    }
                    this.Provider = DataProvider.OleDBDataProvider;
                }
                else
                {
                    this.DataSource = tempConnString.ToLower().Contains("unicode") ? DataSource.OracleDataSource : DataSource.SqlDataSource;
                    this.Provider = tempConnString.ToLower().Contains("unicode") ? DataProvider.OracleDataProvider : DataProvider.SqlDataProvider;
                }

                if (!Dialog.DataSources.Contains(this.DataSource))
                    Dialog.DataSources.Add(this.DataSource);
                Dialog.SelectedDataSource = this.DataSource;

                foreach (DataProvider objDataProvider in Dialog.SelectedDataSource.Providers)
                {

                    if (objDataProvider.Name == "System.Data.OleDb" && this.Provider.Equals(DataProvider.OleDBDataProvider))
                    {
                        Dialog.SelectedDataProvider = objDataProvider;
                        break;
                    }

                    if (objDataProvider.Name == "System.Data.OracleClient" && this.Provider.Equals(DataProvider.OracleDataProvider))
                    {
                        Dialog.SelectedDataProvider = objDataProvider;
                        break;
                    }
                    if (objDataProvider.Name == "System.Data.SqlClient" && this.Provider.Equals(DataProvider.SqlDataProvider))
                    {
                        Dialog.SelectedDataProvider = objDataProvider;
                        break;
                    }
                }

                if (!string.IsNullOrEmpty(tempConnString))
                {
                    Dialog.ConnectionString = tempConnString;
                }

            }
            catch
            {

            }
            return this.GetConnString();
        }
Esempio n. 3
0
 private void btChoose_Click(object sender, EventArgs e)
 {
     DataConnectionDialog dialog = new DataConnectionDialog();
     dialog.DataSources.Add(DataSource.SqlDataSource);
     dialog.DataSources.Add(DataSource.OracleDataSource);
     dialog.DataSources.Add(DataSource.OdbcDataSource);
     dialog.DataSources.Add(DataSource.AccessDataSource);
     dialog.DataSources.Add(DataSource.SqlFileDataSource);
     dialog.SelectedDataSource = DataSource.SqlDataSource;
     dialog.SelectedDataProvider = DataProvider.SqlDataProvider;
     if (DataConnectionDialog.Show(dialog) == DialogResult.OK)
     {
         this.connectionString = dialog.ConnectionString;
         this.dbProvider = dialog.SelectedDataProvider;
     }
 }
Esempio n. 4
0
 public string GetConnString()
 {
     if (DataConnectionDialog.Show(this.Dialog) == DialogResult.OK)
     {
         this.ConnString = Dialog.ConnectionString;
         this.DataSource = Dialog.SelectedDataSource;
         this.Provider = Dialog.SelectedDataProvider;
     }
     return this.ConnString;
 }