Code:
[WebMethod]
public string[] FeaturedGames()
{
OleDbConnection connection3 = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\\Temp\\GamesDatabase.accdb");
connection3.Open();
OleDbCommand cmd = new OleDbCommand("Select Game_ID from Game_Feedback where Rating > 7", connection3);
OleDbDataReader reader = cmd.ExecuteReader();
reader.Read();
int Featured = reader.GetInt32(0);
reader.Close();
cmd = new OleDbCommand("Select Count(Game_Title) from Game_Overview where Game_ID=@Game_ID", connection3);
cmd.Parameters.AddWithValue("@Game_ID", Featured);
reader = cmd.ExecuteReader();
reader.Read();
int numberofgames = reader.GetInt32(0);
reader.Close();
String[] GameTitle = new string[numberofgames];
cmd = new OleDbCommand("Select Game_Title from Game_Overview where Game_ID=@Game_ID", connection3);
cmd.Parameters.AddWithValue("Game_ID", Featured);
reader = cmd.ExecuteReader();
int j = 0;
while (reader.Read())
{
GameTitle[j] = reader.GetString(0);
j++;
}
reader.Close();
connection3.Close();
return GameTitle;
}
Error Code:
System.Data.OleDb.OleDbException: Data type mismatch in criteria expression.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OleDb.OleDbCommand.ExecuteReader()
at GamesWebService.Service1.FeaturedGames() in C:\Users\Jereld\Documents\Visual Studio 2010\Projects\GamesWebServiceBackup\GamesWebService\Service1.asmx.cs:line 126