ViewState passed ID [OleDbException (0x80040e07): Data type mismatchin criteria expression.] error?

  • Thread starter Thread starter DC
  • Start date Start date
D

DC

Any idea why this code would cause a [OleDbException (0x80040e07): Data
type mismatch in criteria expression.] error?

The SQL that gets executed seems to be (using record 1132 as an example)

DELETE FROM user_table WHERE ID = '1132';

And the value of ViewState("ID") =1132

ID is an Access database autonumber field. Is Viewstate data passed as
an odd type or something?

Thanks in advance,

Code
____________________________________________________________________________

Sub Get_Command (Src As Object, Args As DetailsViewCommandEventArgs)

If Args.CommandName = "Yes" Then
DetailsSource.DeleteCommand = "DELETE FROM user_table WHERE ID = '"
& ViewState("ID") & "';"
DetailsSource.Delete()
GridView.DataBind()
EditMSG.Text = " Record " & ViewState("ID") & " deleted"
End If

End Sub
 
DELETE FROM user_table WHERE ID = '1132';

Try;

DELETE FROM user_table WHERE ID = 1132;

Note the lack of quotes.
 
Back
Top