public static void RefreshCharacterSets(string cn_name) { string cmd0 = "SELECT RDB$CHARACTER_SETS.RDB$CHARACTER_SET_NAME FROM RDB$CHARACTER_SETS"; string cmd = cmd0 + ";"; ConnectionClass cc = ConnectionPoolClass.Instance().GetConnection(cn_name); cc.ShowExceptionMode = MessageLibrary.ShowError.no; DbDataReader dr = cc.ExecuteQuery(cmd, false); if (dr != null) { if (cc.HasRows()) { int n = 0; while (cc.Read()) { string cset = cc.GetValue(0).ToString().Trim(); n++; } } cc.CloseConnection(); } }
public void RefreshDomain() { string cmd0 = "SELECT RDB$FIELDS.RDB$FIELD_NAME,RDB$FIELDS.RDB$CHARACTER_LENGTH,RDB$FIELDS.RDB$FIELD_SCALE,RDB$FIELD_PRECISION,RDB$FIELDS.RDB$FIELD_TYPE,RDB$FIELDS.RDB$DESCRIPTION,RDB$TYPES.RDB$TYPE_NAME FROM RDB$FIELDS"; string cmd1 = "LEFT JOIN RDB$TYPES ON RDB$TYPES.RDB$TYPE = RDB$FIELDS.RDB$FIELD_TYPE"; string where = "WHERE RDB$FIELDS.RDB$FIELD_NAME = '" + FieldObject.Domain + "' AND RDB$TYPES.RDB$FIELD_NAME = 'RDB$FIELD_TYPE'"; string cmd = cmd0 + " " + cmd1 + " " + where + ";"; ConnectionClass cc = ConnectionPoolClass.Instance().GetConnection("C1"); cc.ShowExceptionMode = MessageLibrary.ShowError.no; DbDataReader dr = cc.ExecuteQuery(cmd, false); if (dr != null) { if (cc.HasRows()) { int n = 0; while (cc.Read()) { DomainObject = DataClassFactory.GetDataClass(StaticVariablesClass.DomainsKeyStr) as DomainClass; DomainObject.Name = cc.GetValue(0).ToString().Trim(); DomainObject.Length = StaticFunctionsClass.ToIntDef(cc.GetValue(1).ToString().Trim(), 0); DomainObject.Scale = StaticFunctionsClass.ToIntDef(cc.GetValue(2).ToString().Trim(), 0); DomainObject.Precision = StaticFunctionsClass.ToIntDef(cc.GetValue(3).ToString().Trim(), 0); DomainObject.TypeNumber = StaticFunctionsClass.ToIntDef(cc.GetValue(4).ToString().Trim(), 0); DomainObject.FieldType = cc.GetValue(6).ToString().Trim(); DomainObject.RawType = StaticVariablesClass.ConvertINTERNALType_TO_SQLType(DomainObject.FieldType, DomainObject.Length); object ob = cc.GetValue(5); DomainObject.Description = cc.GetValue(5).ToString().Trim(); /* * if (!string.IsNullOrEmpty(ob.ToString())) * { * byte[] bytetext = (byte[])cc.DBProvider.DataReader[3]; * DomainObject.Description = System.Text.Encoding.UTF8.GetString(bytetext); * } */ n++; } } cc.CloseConnection(); } }
public void GetConnections() { lvConnections.Items.Clear(); foreach (ConnectionClass c in ConnectionPoolClass.Instance().Connections) { string[] cn = new string[3]; cn[0] = c.ConnName; cn[1] = "open"; if (c.ConnectionIsClosed()) { cn[1] = "closed"; } cn[2] = ""; ListViewItem lvi = new ListViewItem(cn); lvi.Tag = c; lvConnections.Items.Add(lvi); } }
private void hotSpot1_Click(object sender, EventArgs e) { ConnectionPoolClass.Instance().CloseAllConnections(); }
public void GetConstraints() { ConnectionClass cc = ConnectionPoolClass.Instance().GetConnection("TABLE1"); cc.ShowExceptionMode = MessageLibrary.ShowError.no; string cmd_index0 = "SELECT RDB$INDICES.RDB$INDEX_NAME as Name,RDB$RELATION_CONSTRAINTS.RDB$CONSTRAINT_TYPE as FieldType"; string cmd_index1 = "FROM RDB$INDICES"; string cmd_index2 = "LEFT JOIN RDB$RELATION_CONSTRAINTS ON RDB$RELATION_CONSTRAINTS.RDB$INDEX_NAME = RDB$INDICES.RDB$INDEX_NAME"; string cmd_index_where = "WHERE RDB$INDICES.RDB$RELATION_NAME = '" + TabName + "'"; string cmd_index = cmd_index0 + " " + cmd_index1 + " " + cmd_index2 + " " + cmd_index_where + ";"; dataSet1.Clear(); dataGridView1.AutoGenerateColumns = true; //string cmd = "SELECT * FROM " + TableObject.Name + ";"; /* * spezialfilterBox1.SQLKonjunktion = "WHERE"; * string SCmd = spezialfilterBox1.SQLCmd; * if (SCmd.Length > 0) * { * sb.Append(SCmd); * } * * sb.Append(";"); */ cc.FillDataset(cmd_index, dataSet1); cc.CloseReader(); bindingSource1.DataMember = "Table"; /* * n++; * if (cc.ExecuteQuery(cmd_index, false) != null) * { * * while (cc.Read()) * { * string index_name = cc.GetValue(0).ToString().Trim(); * string constraint_type = cc.GetValue(1).ToString().Trim(); * int indexid = StaticFunctionsClass.ToIntDef(cc_index.GetValue(2).ToString().Trim(), -1); * if ((constraint_type == "PRIMARY KEY") && (n == indexid)) * { * tfc.IS_PRIMARY = true; * tfc.IS_UNIQUE = true; * } * } * } * * tfc.Domain.Length = StaticFunctionsClass.ToIntDef(cc.GetValue(5).ToString().Trim(), 0); * tfc.Domain.FieldType = cc.GetValue(4).ToString().Trim(); * tfc.Domain.RawType = StaticVariablesClass.ConvertType(tfc.Domain.FieldType, tfc.Domain.Length); * tfc.Position = StaticFunctionsClass.ToIntDef(cc.GetValue(2).ToString().Trim(), 0); * tfc.Domain.Name = cc.GetValue(6).ToString().Trim(); * tfc.Domain.Scale = StaticFunctionsClass.ToIntDef(cc.GetValue(7).ToString().Trim(), 0) * -1; */ }
private void hsRestore_Click(object sender, EventArgs e) { n = 0; var ca = new ConnectionAttributes(); ca.Server = DBReg.Server; //SE ca.Client = DRC.Client; ca.DatabasePath = txtRestoreDetinationDatabasePath.Text; ca.Password = DBReg.Password; ca.User = DBReg.User; ca.ConnectionType = DBReg.ConnectionType; ca.CharSet = DBReg.CharSet; ca.PacketSize = DBReg.PacketSize; ca.Port = DBReg.Port; string connstr = ConnectionStrings.Instance().MakeConnectionString(ca); lvRestoreMessage.Items.Clear(); var bu = new RestoreClass(connstr); bu.Restore.ServiceOutput += Restore_ServiceOutput; var lf = new List <FirebirdSql.Data.Services.FbBackupFile>(); for (int i = 0; i < lvRestore.Items.Count; i++) { ListViewItem lvi = lvRestore.Items[i]; FirebirdSql.Data.Services.FbBackupFile bf = (FirebirdSql.Data.Services.FbBackupFile)lvi.Tag; lf.Add(bf); } bu.SetFiles(lf.ToArray()); if (rbReplaceDatabase.Checked) { bu.AddOptions(FirebirdSql.Data.Services.FbRestoreFlags.Replace); } else { bu.AddOptions(FirebirdSql.Data.Services.FbRestoreFlags.Create); } if (cbRestoreNoIndices.Checked) { bu.AddOptions(FirebirdSql.Data.Services.FbRestoreFlags.DeactivateIndexes); } if (cbRestoreNoShadows.Checked) { bu.AddOptions(FirebirdSql.Data.Services.FbRestoreFlags.NoShadow); } if (cbRestoreInvidualCommit.Checked) { bu.AddOptions(FirebirdSql.Data.Services.FbRestoreFlags.IndividualCommit); } if (cbRestoreMetatdataOnly.Checked) { bu.AddOptions(FirebirdSql.Data.Services.FbRestoreFlags.MetaDataOnly); } if (cbRestoreNoVaildy.Checked) { bu.AddOptions(FirebirdSql.Data.Services.FbRestoreFlags.NoValidity); } if (cbRestoreUseAllSpace.Checked) { bu.AddOptions(FirebirdSql.Data.Services.FbRestoreFlags.UseAllSpace); } ConnectionPoolClass.Instance().CloseAllConnections(); if (ConnectionPoolClass.Instance().AktCON != null) { ConnectionPoolClass.Instance().AktCON.Close(); } bu.Execute(); DbExplorerForm.Instance().MakeDatabaseTree(true); }