コード例 #1
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();

            form2.StartPosition = FormStartPosition.CenterScreen;
            if (form2.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            conStr = form2.ConStr;
            LoadDb();
        }
コード例 #2
0
        public static string GetSql(DbConStrInfo conStr, int type, string table_name = "")
        {
            if (type == 1)
            {
                if (conStr.ProviderType == ProviderType.MySql)
                {
                    return(string.Format("select * from information_schema.tables where table_schema='{0}'", conStr.Database));
                }
                if (conStr.ProviderType == ProviderType.SqlServer)
                {
                    return(string.Format("select name as table_name from sys.objects where type='U' order by name"));
                }
                if (conStr.ProviderType == ProviderType.Oracle)
                {
                    return("select table_name from user_tables");
                }
            }

            if (type == 2)
            {
                if (conStr.ProviderType == ProviderType.MySql)
                {
                    return(string.Format("select * from information_schema.views where table_schema='{0}'", conStr.Database));
                }
                if (conStr.ProviderType == ProviderType.SqlServer)
                {
                    return(string.Format("select name as table_name from sys.objects where type='V'  order by name"));
                }
                if (conStr.ProviderType == ProviderType.Oracle)
                {
                    return("select * from user_views");
                }
            }

            if (type == 3)
            {
                if (conStr.ProviderType == ProviderType.MySql)
                {
                    return(string.Format("select  * from information_schema.columns where table_schema='{0}' and table_name='{1}'",
                                         conStr.Database, table_name));
                }
                if (conStr.ProviderType == ProviderType.SqlServer)
                {
                    return(string.Format("SELECT * FROM sys.columns WHERE OBJECT_ID = (SELECT id  FROM sys.sysobjects WHERE type IN ('U','V') AND name='{0}')", table_name));
                }
                if (conStr.ProviderType == ProviderType.Oracle)
                {
                    return(string.Format("select * from USER_TAB_COLUMNS where table_name='{0}'", table_name));
                }
            }
            return("");
        }
コード例 #3
0
 public static int ExecuteNonQuery(DbConStrInfo conStr, string sql)
 {
     if (conStr.ProviderType == ProviderType.MySql)
     {
         return(MySqlConnector.ExecuteNonQuery(conStr.ConStr, sql));
     }
     else if (conStr.ProviderType == ProviderType.Oracle)
     {
         return(OracleConnector.ExecuteNonQuery(conStr.ConStr, sql));
     }
     else
     {
         return(SqlConnector.ExecuteNonQuery(conStr.ConStr, sql));
     }
 }
コード例 #4
0
 public static DataTable GetData(DbConStrInfo conStr, string sql)
 {
     if (conStr.ProviderType == ProviderType.MySql)
     {
         return(MySqlConnector.GetData(conStr.ConStr, sql));
     }
     else if (conStr.ProviderType == ProviderType.Oracle)
     {
         return(OracleConnector.GetData(conStr.ConStr, sql));
     }
     else
     {
         return(SqlConnector.GetData(conStr.ConStr, sql));
     }
 }
コード例 #5
0
 public static bool TestConnect(DbConStrInfo conStr)
 {
     if (conStr.ProviderType == ProviderType.MySql)
     {
         return(MySqlConnector.TestConnect(conStr.ConStr));
     }
     else if (conStr.ProviderType == ProviderType.Oracle)
     {
         return(OracleConnector.TestConnect(conStr.ConStr));
     }
     else
     {
         return(SqlConnector.TestConnect(conStr.ConStr));
     }
 }
コード例 #6
0
ファイル: Form2.cs プロジェクト: zzia615/SqlFastQuery
 private void button3_Click(object sender, EventArgs e)
 {
     ConStr = new DbConStrInfo
     {
         Server   = tb_server.Text,
         Port     = tb_port.Text,
         LogId    = tb_logid.Text,
         LogPass  = tb_logpass.Text,
         Database = cbb_db.Text,
         Provider = cbb_provider.Text
     };
     if (AppFunc.TestConnect(ConStr))
     {
         MessageBox.Show("连接数据库成功!", "提示信息");
     }
     ConStr = null;
 }
コード例 #7
0
ファイル: Form2.cs プロジェクト: zzia615/SqlFastQuery
 private void button1_Click(object sender, EventArgs e)
 {
     ConStr = new DbConStrInfo
     {
         Server   = tb_server.Text,
         Port     = tb_port.Text,
         LogId    = tb_logid.Text,
         LogPass  = tb_logpass.Text,
         Database = cbb_db.Text,
         Provider = cbb_provider.Text
     };
     if (!AppFunc.TestConnect(ConStr))
     {
         ConStr = null;
         return;
     }
     SaveXml("db_config.xml");
     this.DialogResult = DialogResult.OK;
 }
コード例 #8
0
ファイル: Form2.cs プロジェクト: zzia615/SqlFastQuery
 private void button2_Click(object sender, EventArgs e)
 {
     ConStr            = null;
     this.DialogResult = DialogResult.Cancel;
 }
コード例 #9
0
ファイル: Form3.cs プロジェクト: zzia615/SqlFastQuery
 public Form3(string table, DbConStrInfo conStr)
 {
     InitializeComponent();
     this.table  = table;
     this.conStr = conStr;
 }