Type Mismatch in QueryString

Hi,
I'm using the following two snippets but keep getting a type mismatch error

Listing Page
"<TD BGCOLOR=""" & BCol & """ ALIGN=""right"">" & "<A HREF=""newsletter.asp?mode=deletemail&id=" & rs("MailHistoryID") & """>" & "Delete" & "</A>" & "</TD></TR>" & vbcrlf

Delete Page
If Request.QueryString("mode") = "deletemail" Then

intMailHistoryID = Request.QueryString("id")
strSQL = "DELETE * FROM MailHistory WHERE MailHistoryID = '" & intMailHistoryID & "'"

'Response.write intMailHistoryID
'Response.End

Conn.Execute(strSQL)

The response .write shows the value of the MailHistory id but the SQL won't execute because of the type mismatch.

Any help much appreciated.
gillmcdAsked:
Who is Participating?
 
nilapennConnect With a Mentor Commented:
If Mailhistoryid is integer then remove the single quotes

strSQL = "DELETE * FROM MailHistory WHERE MailHistoryID = " & intMailHistoryID
0
 
gbarenCommented:
You have single quotes around an integer value. Single quotes specify a char value. Your type mismatch is from trying to set an integer column to a character value.
0
 
Michel SakrCommented:
you must remove the star:

strSQL = "DELETE FROM MailHistory WHERE MailHistoryID = " & intMailHistoryID

0
 
yitz99Commented:
looks like you've got good suggestions above.

General tip - print out sql statements that give you trouble. ie:

response.write vbcrlf & "<!-- SQL: " & strSQL & "-->" & vbcrlf

that will troubleshoot it for you most of the time.
0
 
gillmcdAuthor Commented:
Thanks guys I learned a number of useful things from this.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.