ここに私が試したことのコードスニペットがあります:
private static void CheckForChanges(MySqlConnection connection)
{
DateTime hair = DateTime.Parse(SmartStyleDataset.Tables["Hair"].Compute("MAX(lastUpdated)", null).ToString());
DateTime cloths = DateTime.Parse(SmartStyleDataset.Tables["Cloths"].Compute("MAX(lastUpdated)", null).ToString());
DateTime accessories = DateTime.Parse(SmartStyleDataset.Tables["Accessories"].Compute("MAX(lastUpdated)", null).ToString());
DateTime cosmetics = DateTime.Parse(SmartStyleDataset.Tables["Cosmetics"].Compute("MAX(lastUpdated)", null).ToString());
List<String>[] NewRows = { new List<String>(), new List<String>(), new List<String>(), new List<String>() };
using (var command = connection.CreateCommand())
{
connection.Open();
command.CommandText =
"SELECT * "
+ "FROM smartstyle.table_changes_logger "
+ "WHERE Updated > @accessories AND Table = 'accessories' ; "
+ "SELECT * "
+ "FROM smartstyle.table_changes_logger "
+ "WHERE Updated > @cosmetics AND Table = 'cosmetics' ; "
+ "SELECT * "
+ "FROM smartstyle.table_changes_logger "
+ "WHERE Updated > @cloths AND Table = 'cloths' ; "
+ "SELECT * "
+ "FROM smartstyle.table_changes_logger "
+ "WHERE Updated > @hair AND Table = 'hair'";
command.Parameters.Add("@cloths", MySql.Data.MySqlClient.MySqlDbType.Timestamp).Value = cloths.ToString("yyyy-MM-dd HH:mm:ss");
command.Parameters.Add("@hair", MySql.Data.MySqlClient.MySqlDbType.Timestamp).Value = hair.ToString("yyyy-MM-dd HH:mm:ss");
command.Parameters.Add("@accessories", MySql.Data.MySqlClient.MySqlDbType.Timestamp).Value = accessories.ToString("yyyy-MM-dd HH:mm:ss");
command.Parameters.Add("@cosmetics", MySql.Data.MySqlClient.MySqlDbType.Timestamp).Value = cosmetics.ToString("yyyy-MM-dd HH:mm:ss");
using (var reader = command.ExecuteReader())
{
do
{
while (reader.Read())
{
NewRows[0].Add(reader.GetString(1));
NewRows[1].Add(reader.GetString(2));
NewRows[2].Add(reader.GetString(3));
NewRows[3].Add(reader.GetString(4));
}
} while (reader.NextResult());
}
}
}
しかし、これは機能しません。mysql から次の一般的なエラーが 発生します。理解できません。SQL 構文にエラーがあります。near 'Table = 'accessories' ; を使用する正しい構文については、MySQL サーバーのバージョンに対応するマニュアルを確認してください。SELECT * FROM smartstyle.table_changes_logger WHERE Upd' at line 1