dotNet.loadAssembly "C:\\Program Files (x86)\\MySQL\\MySQL Connector NET 8.2.0\\MySql.Data.dll" host = "81.71.134.168" -- The name of the MySQL server database = "admin" -- The name of the database to use user = "admin123" -- The user name to use password = "aiAtB23yajDj2Lpa" -- The password to use connectionString = "Database=" + database + ";Data Source=" + host + ";User Id=" + user + ";Password=" + password DBConnection = dotNetObject "MySql.Data.MySqlClient.MySqlConnection" DBConnection.ConnectionString = connectionString DBConnection.open() -- Print the connection status: 1 - connected; 0 - not connected. print DBConnection.state.value__ -- Add a new rows cmdObject = DBConnection.CreateCommand() cmdObject.commandText ="INSERT INTO `admin`.`students`(`id`, `name`, `age`, `score`, `birthday`, `insert_time`) VALUES (132, 'name03', 16, 35, '2023-11-23', '2023-12-13 10:50:56')" readerObject = cmdObject.ExecuteReader() -- 打印受影响的行数 format "添加了 % 行\n" readerObject.RecordsAffected readerObject.close() -- 查询数据库: -- 首先创建一个命令对象。该对象用于将查询发送到数据库。 cmdObject = DBConnection.CreateCommand() -- 定义要执行的SQL查询: cmdObject.commandText = "SELECT * FROM `admin`.`students`" -- 然后执行命令以创建读取器对象。 readerObject = cmdObject.ExecuteReader()