Beispiel #1
0
        /// <summary>
        /// 表示给表格添加内容,按照默认顺序
        /// </summary>
        public void Insert(string tableName, params string[] contents)
        {
            string sqlCmd = "INSERT INTO " + tableName + " VALUES ";

            string c = "(";

            for (int i = 0; i < contents.Length; i++)
            {
                c += "'" + contents[i] + "'";

                if (i != contents.Length - 1)
                {
                    c += ",";
                }
                else
                {
                    c += ")";
                }
            }

            sqlCmd += c;

            hunterConsole.WriteDetails(sqlCmd);
            try
            {
                MySqlCommand sqlCommand = new MySqlCommand(sqlCmd, mysql_connection);
                sqlCommand.ExecuteNonQuery();
            }
            catch (MySqlException e)
            {
                hunterConsole.WriteException(e);
            }
        }
Beispiel #2
0
 public void createDatabase()
 {
     try
     {
         XDocument xdoc = new XDocument(new XDeclaration("1,0", "utf-8", "yes"),
                                        new XElement(XMLDefinition.ElementName.root.ToString()));
         if (xmlDatabasePath.Length <= 0)
         {
             mHunterConsole.WriteMessage("XML数据库文件名为空!");
         }
         else
         {
             xdoc.Save(xmlDatabasePath);
             mHunterConsole.WriteMessage("建立XML数据库成功。");
             openDatabase();
         }
     }
     catch (Exception e) { mHunterConsole.WriteException(e); }
 }