I'm trying to updatesome records, currently my table is blank apart from the user id which is correct. but i get the error below.
My UserSettings table is as follows
ID is a Integer
MonthID is a Integer
YearID is a Integer
UserName is a string
Balance is a Integer
PhotoAddress is a string
GameSpeed is a Integer
This is my code and below that is my error in my ErrorTXT box.
Anyidea what is wrong?
vb.net Code:
Try Using connection As New OleDb.OleDbConnection(My.Settings.AirlineConnectionString) Using command As New OleDb.OleDbCommand("UPDATE UserSettings SET MonthID = @MonthID, YearID = @YearID, UserName = @UserName, Balance = @Balance, PhotoAddress = @PhotoAddress, GameSpeed = @GameSpeed WHERE UserID = " & CInt(GameMainWindow.ValuesUserIDTxt.Text), connection) connection.Open() command.Parameters.AddWithValue("@ID", CInt(GameMainWindow.ValuesUserIDTxt.Text)) command.Parameters.AddWithValue("@MonthID", CInt(GameMainWindow.ValuesGameMonthTxt.Text)) command.Parameters.AddWithValue("@YearID", CInt(GameMainWindow.ValuesGameYearTxt.Text)) command.Parameters.AddWithValue("@UserName", GameMainWindow.ValuesUserNameTxt.Text) command.Parameters.AddWithValue("@Balance", CInt(GameMainWindow.ValuesBalanceTxt.Text)) command.Parameters.AddWithValue("@PhotoAddress", GameMainWindow.ValuesPhotoAddressTxt.Text) command.Parameters.AddWithValue("@GameSpeed", CInt(GameMainWindow.ValuesGameSpeedTxt.Text)) command.ExecuteNonQuery() connection.Close() End Using End Using Catch ex As Exception GameMainWindow.ErrorTXT.Text = ex.ToString End Try
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.ExecuteNonQuery() at Airline_Sim.MainMod.SaveGame() in C:\Documents and Settings\Me\My Documents\Visual Studio 2008\Projects\Airliine Sim\Airliine Sim\GameData\MainMod.vb:line 25




Reply With Quote