public void TestSqlServerLog() { SqlExecutePatcher.Patch(); object ret; string val = "1578"; using (var connection = new SqlConnection("server=10.2.5.2;database=master;uid=sa;pwd=123456")) using (var command = connection.CreateCommand()) { connection.Open(); command.CommandText = "select " + val; _logger.Info("准备执行SqlServer语句"); ret = command.ExecuteScalar(); } Assert.AreEqual(ret.ToString(), val); }
public void TestMySqlLog() { SqlExecutePatcher.Patch(); object ret; var constr = "server=10.2.5.2;Port=3306;Database=mysql;uid=root;pwd=123456;Pooling=True;Max Pool Size=10;Charset=utf8"; string val = "1578"; using (var connection = new MySqlConnection(constr)) using (var command = connection.CreateCommand()) { connection.Open(); command.CommandText = "select " + val + " from dual"; _logger.Info("准备执行MySql语句"); ret = command.ExecuteScalar(); } Assert.AreEqual(ret.ToString(), val); }