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>()); } }
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); }
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>()); } }
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); }
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); }