Esempio n. 1
0
        public static DataSet ExecuteQuery(Server svr, string query)
        {
            DataSet tmpSet = new DataSet();
            string[] pQuery = ParseQuery(query);
            svr.Connector.Open();

            for (int i = 0; i < pQuery.Length; i++)
                if (bgwQueryRunner.CancellationPending) i = pQuery.Length;
                else
                {
                    try
                    {
                        DataTable tmpTable = new DataTable();
                        SqlCommand sqlCmd = new SqlCommand(pQuery[i], svr.Connector);
                        sqlCmd.CommandTimeout = 0;
                        SqlDataAdapter tmpCom = new SqlDataAdapter(sqlCmd);
                        tmpCom.Fill(tmpTable);
                        if (tmpTable.Columns.Count > 0) tmpSet.Tables.Add(tmpTable);

                    }
                    catch (Exception ex)
                    { QMain.ReportEx(ex, "QQuery", "ExecuteQuery"); svr.Connector.Close(); }
                }

            svr.Connector.Close();
            return tmpSet;
        }
Esempio n. 2
0
        public static List<Table> GetTableList(string db, Server svr)
        {
            svr.ConnectorDB = db;
            SqlConnection conn = svr.Connector;
            List<Table> tblList = new List<Table>();
            try
            {
                string dbQuery = "SELECT table_name, table_schema FROM Information_Schema.Tables where Table_Type = 'BASE TABLE' ORDER BY table_name";

                conn.Open();

                SqlCommand tmp1 = new SqlCommand(dbQuery, conn);
                SqlDataReader rdFirstSet = tmp1.ExecuteReader();

                while (rdFirstSet.Read())
                {
                    Table tmpTable = new Table();
                    tmpTable.TableName = rdFirstSet[0].ToString();
                    tmpTable.TableSchema = rdFirstSet[1].ToString();
                    tblList.Add(tmpTable);
                }

                conn.Close();
            }
            catch (Exception ex)
            {
                QEngine_Main.ReportEx(ex, "QEngine_Info", "GetTableList");
            }
            return tblList;
        }
Esempio n. 3
0
 public bool Initialize(Server Server)
 {
     try
     {
         Server = new Server(Server); Load();
         UI = new QueryUI(Server) as UserControl;
         return true;
     }
     catch (Exception ex)
     { QMain.ReportEx(ex, "QueryUtility", "Initialize(Server)"); return false; }
 }
Esempio n. 4
0
        public bool Initialize()
        {
            string svr = "";

            if (SetConnection(ref svr))
            {
                Server = new Server(svr); Load();
                UI = new QueryUI(Server) as UserControl;
                return true;
            }
            return false;
        }
Esempio n. 5
0
File: QMain.cs Progetto: Zexks/QLite
        public static Server CreateServer(string connection)
        {
            Server tmpSvr = new Server(connection);
            try
            {
                tmpSvr.Connector.Open();
                tmpSvr.Connector.Close();
                tmpSvr.InstanceID = tmpSvr.Machine + "\\" + tmpSvr.Name;
                tmpSvr.LoadDatabaseSet();
            }
            catch (SqlException sql_ex) { ReportEx(sql_ex, "Engine", "CreateServer"); tmpSvr = null; }
            catch (Exception ex) { ReportEx(ex, "Engine", "CreateServer"); tmpSvr = null; }

            return tmpSvr;
        }
Esempio n. 6
0
 public Server(Server svr)
 {
     Databases = svr.Databases;
     DBMap = svr.DBMap;
     Mapped = svr.Mapped;
     InfoMessages = svr.InfoMessages;
     ErrorMessages = svr.ErrorMessages;
     InstanceID = svr.InstanceID;
     Name = svr.Name;
     Machine = svr.Machine;
     UserID = svr.UserID;
     Password = svr.Password;
     ConnectionString = svr.ConnectionString;
     TimeOut = svr.TimeOut;
     Connector = svr.Connector;
 }
Esempio n. 7
0
 public void initializeServer(Server svr)
 {
     _Svr = new Server(svr);
     txtMessages.DataBindings.Add("Text", _Svr, "InfoMessages");
 }
Esempio n. 8
0
File: Table.cs Progetto: Zexks/QLite
 public void LoadColumnSet(Server svr)
 {
     Columns = QInfo.GetColumnList(svr.Connector, TableName);
     ColMap = new ColumnMap(Columns.Count);
 }
Esempio n. 9
0
 public QueryUI(Server svr)
 {
     _Svr = svr;
     InitializeComponent();
 }
Esempio n. 10
0
 public QueryUI(Server svr, string query)
 {
     _Svr = svr;
     InitializeComponent();
 }
Esempio n. 11
0
 public void LoadTableSet(Server svr)
 {
     Tables = QInfo.GetTableList(Name, svr);
     TBLMap = new TableMap(Tables.Count);
 }
Esempio n. 12
0
 public QueryUI()
 {
     _Svr = new Server();
     InitializeComponent();
 }
Esempio n. 13
0
 public bool Initialize(Server Server, string query)
 {
     try
     {
         Server = new Server(Server); Load();
         UI = new QueryUI(Server, query) as UserControl;
         ExecuteQuery_Click(new Object(), new EventArgs());
         return true;
     }
     catch (Exception ex)
     { QMain.ReportEx(ex, "QueryUtility", "Initialize(Server, Query)"); return false; }
 }
Esempio n. 14
0
 public static int StartProcess(ToolStripMenuItem inItem, Server svr)
 {
     string tag = inItem.Tag.ToString();
     string[] tagItems = tag.Split(new char[] {','});
     int process = -1;
     switch (tagItems[0])
     {
         case "Query":
             process = StartQuery("", svr);
             break;
         case "Plugin":
             process = StartPlugin(tagItems);
             if(process != -1)
                 Global.QliteProcesses[process].Page.Tag = Global.QliteProcesses[process].Page.Tag + "," + process.ToString();
             break;
     }
     return process;
 }
Esempio n. 15
0
File: QMain.cs Progetto: Zexks/QLite
 public static int StartProcess(TreeNode inNode, Server svr)
 {
     string query = "SELECT * FROM " + inNode.Text.ToUpper();
     return StartQuery(query, svr);
 }
Esempio n. 16
0
File: QMain.cs Progetto: Zexks/QLite
 public static int StartProcess(ToolStripItem inItem, Server svr)
 {
     string tag = inItem.Tag.ToString();
     string[] tagItems = tag.Split(new char[] {','});
     int process = Global.Processes.Count();
     foreach (var p in Global.Plugins.Catalog.Parts)
         foreach (var ed in p.ExportDefinitions)
             if (ed.ContractName == "IPlugin")
                 foreach (var meta in ed.Metadata)
                     if (meta.Key == "Name" && meta.Value == tag)
                     {
                         //process = StartPlugin(tag);
                         process = StartPlugin((IPlugin)p);
                         Global.Processes[process].UI.Tag = Global.Processes[process].UI.Tag + ", " + process.ToString();
                     }
     return process;
 }
Esempio n. 17
0
File: QMain.cs Progetto: Zexks/QLite
 private static int StartQuery(string query, Server svr)
 {
     QueryPlug tmpQuery = new QueryPlug();
     if (svr.Connector == null && tmpQuery.Initialize()) return SetProcess(tmpQuery);
     else
     {
         if (query == "" && tmpQuery.Initialize(svr)) return SetProcess(tmpQuery);
         else if (tmpQuery.Initialize(svr, query)) return SetProcess(tmpQuery);
     }
     return -1;
 }