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

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
 
A

Aidy

DELETE FROM user_table WHERE ID = '1132';

Try;

DELETE FROM user_table WHERE ID = 1132;

Note the lack of quotes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top