Пример #1
0
        public void SQLConnSet_BtnConnClick(ConnSet connSet, UiShow uiShow)
        {
            using (SqlConnection connection = CreateConnection(connSet))
            {
                connection.Open();

                uiShow.lbTableName.Items.Clear();
                IEnumerable<object> enumerable = connection.Query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' ORDER BY TABLE_NAME ASC;", null, null, true, null, null);
                uiShow.lbTableName.Items.AddRange((from d in enumerable select ((dynamic)d).TABLE_NAME).ToArray<object>());
            }
        }
Пример #2
0
        public void MySqlConnSet_BtnConnClick(ConnSet connSet, UiShow uiShow)
        {
            StringBuilder sb = new StringBuilder();
            foreach (var item in TableNames)
            {
                sb.AppendLine(GenerateCode(item as string));
            }

            System.IO.File.WriteAllText("ORM.cs", sb.ToString());

            uiShow.lbTableName.Items.Clear();
            uiShow.lbTableName.Items.AddRange(TableNames);
        }
Пример #3
0
        public void pgAdminConnSet_BtnConnClick(ConnSet connSet, UiShow uiShow)
        {
            using (NpgsqlConnection connection = CreateConnection(connSet))
            {
                connection.Open();

                uiShow.lbTableName.Items.Clear();
                string sql =
                    $"SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_catalog='{connection.Database}' AND table_schema='public' AND table_type='BASE TABLE' ORDER BY table_name ASC;";
                IEnumerable<object> enumerable = connection.Query(sql, null, null, true, null, null);
                uiShow.lbTableName.Items.AddRange((from d in enumerable select ((dynamic)d).table_name).ToArray<object>());
            }
        }
Пример #4
0
 private SqlConnection CreateConnection(ConnSet connSet)
 {
     if (string.IsNullOrEmpty(ConnectionString))
     {
         SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder
         {
             DataSource = connSet.txtDbIP.Text,
             UserID = connSet.txtUserName.Text,
             Password = connSet.txtPassword.Text,
             InitialCatalog = connSet.txtDbName.Text
         };
         ConnectionString = builder.ToString();
     }
     return new SqlConnection(ConnectionString);
 }
Пример #5
0
 private MySqlConnection CreateConnection(ConnSet connSet)
 {
     if (string.IsNullOrEmpty(ConnectionString))
     {
         MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder
         {
             Server = connSet.txtDbIP.Text,
             UserID = connSet.txtUserName.Text,
             Password = connSet.txtPassword.Text,
             Database = connSet.txtDbName.Text
         };
         ConnectionString = builder.ToString();
     }
     return new MySqlConnection(ConnectionString);
 }