Exemplo n.º 1
0
        private void saveButton_Click(object sender, RoutedEventArgs e)
        {
            SQLInformation.Data.ApplicationDataSetTableAdapters.DBTablesTableAdapter ta = new SQLInformation.Data.ApplicationDataSetTableAdapters.DBTablesTableAdapter();

            ta.Connection.ConnectionString = SQLInformation.Data.Config.SQLMonitorDBConnection;

            ta.Update(Common.ApplicationDataSet.DBTables);
        }
Exemplo n.º 2
0
        private void LoadTables(string instanceName, SQLInformation.Data.ApplicationDataSet.DatabasesRow databaseRow)
        {
#if TRACE
            //long startTicks = Common.WriteToDebugWindow(string.Format("Enter {0}:{1}()", TYPE_NAME, System.Reflection.MethodInfo.GetCurrentMethod().Name));
#endif

            SMO.Server server = SMOH.SMOD.GetServer(instanceName);

            SQLInformation.Data.ApplicationDataSetTableAdapters.DBTablesTableAdapter tableAdapter = new SQLInformation.Data.ApplicationDataSetTableAdapters.DBTablesTableAdapter();
            tableAdapter.Connection.ConnectionString = SQLInformation.Data.Config.SQLMonitorDBConnection;

            int dbID = databaseRow.ID_DB;

            SMO.Database db = server.Databases.ItemById(dbID);

            foreach (SMO.Table table in db.Tables)
            {
                SMOH.Table tableH = new SMOH.Table(table);

                SQLInformation.Data.ApplicationDataSet.DBTablesRow newTable = Common.ApplicationDataSet.DBTables.NewDBTablesRow();

                newTable.ID            = Guid.NewGuid(); // See if this is available from table.
                newTable.Name_Table    = tableH.Name;
                newTable.Table_ID      = tableH.ID;
                newTable.Database_ID   = databaseRow.ID; // From above
                newTable.Owner         = tableH.Owner;
                newTable.CreateDate    = DateTime.Parse(tableH.CreateDate);
                newTable.DataSpaceUsed = int.Parse(tableH.DataSpaceUsed);

                try
                {
                    newTable.DateLastModified = DateTime.Parse(tableH.DateLastModified);
                }
                catch (Exception ex)
                {
                }

                newTable.RowCount = int.Parse(tableH.RowCount);

                Common.ApplicationDataSet.DBTables.AddDBTablesRow(newTable);
                tableAdapter.Update(Common.ApplicationDataSet.DBTables);
            }
#if TRACE
            //Common.WriteToDebugWindow(string.Format("Exit {0}:{1}()", TYPE_NAME, System.Reflection.MethodInfo.GetCurrentMethod().Name), startTicks);
#endif
        }