Exemplo n.º 1
0
        public List <sys_dic> getsysdic(string tablename)
        {
            string sql = "select * from sys_dic where table_name = '" + tablename + "'";

            MySqlParameter[]    parms = null;
            Helpers.MySqlHelper a     = new Helpers.MySqlHelper();
            DataTable           dt    = a.ExecuteDataTable(sql, parms);
            List <sys_dic>      list  = new List <sys_dic>();

            list = DataTableExtend.ToDataList <sys_dic>(dt);
            return(list);
        }
Exemplo n.º 2
0
    private void query()
    {
        string querySQL = "select * from comment_info ";
        List <Dictionary <string, string> > result = MySqlHelper.query(querySQL, null);

        foreach (Dictionary <string, string> row in result)
        {
            string id, va;
            row.TryGetValue("id", out id);
            row.TryGetValue("content", out va);
            Debug.Log(id + "   " + va);
        }
    }
Exemplo n.º 3
0
        private void RefreshMysql(String uid, String pwd)
        {
            string mysqlConnStr = "server=" + url.Text + ";user id=" + uid + ";password="******";database=information_schema";  //根据自己的设置

            Helpers.MySqlHelper mysqlHelper = new Helpers.MySqlHelper(mysqlConnStr);

            String sql = "select schema_name name from SCHEMATA ";

            MySqlParameter[] parms = new MySqlParameter[] { };
            DataTable        dt    = mysqlHelper.ExecuteDataTable(sql, parms);

            comboBox1.DataSource    = dt;
            comboBox1.DisplayMember = "name";
            comboBox1.ValueMember   = "name";
        }
Exemplo n.º 4
0
    void Start()
    {
//        Debug.Log("开始插入");
//        string insertSQL = "insert into comment_info(id, content) values(@id, @content)";
//        Dictionary<string, object> parameters = new Dictionary<string, object>();
//        parameters.Add("@id", 2);
//        parameters.Add("@content", "2131");
//        MySqlHelper.insertOrUpdate(insertSQL, parameters);
//        Debug.Log("插入完毕");

        query();

        Debug.Log("开始删除");
        string deletSQL = "delete from comment_info where id = @id";
        Dictionary <string, object> parameters1 = new Dictionary <string, object>();

        parameters1.Add("@id", 1);
        MySqlHelper.insertOrUpdate(deletSQL, parameters1);
        Debug.Log("删除完毕");

        query();
    }
Exemplo n.º 5
0
        private void button2_Click(object sender, EventArgs e)
        {
            String uid = username.Text;
            String pwd = password.Text;

            //刷新数据库连接
            if (this.validDbUser(uid, pwd))
            {
                if (rb_sqlserver.Checked) //连接sqlServer
                {
                    String db          = comboBox1.Text;
                    bool   isConnected = this.connectSqlServerDb(db, uid, pwd);

                    if (isConnected)
                    {
                        conn_info.Clear();
                        System.IO.StringWriter   sw = new System.IO.StringWriter();
                        System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(sw);
                        //当前数据库所有的用户表
                        DataTable dt = SqlServerHelper.getTableOfCurrentDatabase();
                        dt.WriteXml(xw);
                        string s = sw.ToString();
                        conn_info.Text = "连接成功……\n所有的用户表展示如下:\n" + s;
                    }
                    else
                    {
                        conn_info.Text = "连接失败……";
                    }
                }
                else if (rb_mysql.Checked) //连接mysql
                {
                    String db          = comboBox1.Text;
                    bool   isConnected = this.connectMySql(db, uid, pwd);
                    if (isConnected)
                    {
                        string mysqlConnStr             = "server=" + url.Text + ";user id=" + uid + ";password="******";database=" + db; //根据自己的设置
                        Helpers.MySqlHelper mysqlHelper = new Helpers.MySqlHelper(mysqlConnStr);

                        String           sql   = "show tables ";
                        MySqlParameter[] parms = new MySqlParameter[] { };
                        DataTable        dt    = mysqlHelper.ExecuteDataTable(sql, parms);

                        conn_info.Clear();
                        System.IO.StringWriter   sw = new System.IO.StringWriter();
                        System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(sw);
                        //当前数据库所有的用户表
                        dt.WriteXml(xw);
                        string s = sw.ToString();
                        conn_info.Text = "连接成功……\n" + s;
                    }
                    else
                    {
                        conn_info.Text = "连接失败……";
                    }
                }
                else if (rb_oracle.Checked)
                {
                    this.RefreshOracle(uid, pwd);
                }
            }
        }