Data Type mismatch in criteria expression
-
Wednesday, February 13, 2013 9:08 AM
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
All Replies
-
Tuesday, February 19, 2013 8:12 AMModerator
Hi JTYR2,
Please refer to this thread:
http://forums.asp.net/t/1509422.aspx/1
Try removing all of the properties and adding them one at a time until you find which one causing the data type mismatch.
Since this problem is a .net problem, please visit ASP.net forum for more help.
Iric Wen
TechNet Community Support- Marked As Answer by Iric WenModerator Thursday, February 21, 2013 9:30 AM



