TeChNiCh
asked on
Trying to delete a record...
i got a little problem when i try to delete a record... i get an error saying "Invalid COUNT-Field"
this is my del code:
ID = Request.QueryString("ID")
StrSQL = "DELETE * from MyTable where ID="& ID
Set ObjRS = objConn.Execute(StrSQL)
never had that problem before, whats wrong??
this is my del code:
ID = Request.QueryString("ID")
StrSQL = "DELETE * from MyTable where ID="& ID
Set ObjRS = objConn.Execute(StrSQL)
never had that problem before, whats wrong??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry typo
it should be if isnumber ...
ID = Request.QueryString("ID")
if isnumber(ID) or len(ID) > 0 Then
StrSQL = "DELETE from MyTable where ID="& ID
Set ObjRS = objConn.Execute(StrSQL)
else
Response.write "Error in passing ID to SQL"
Response.end
end if
it should be if isnumber ...
ID = Request.QueryString("ID")
if isnumber(ID) or len(ID) > 0 Then
StrSQL = "DELETE from MyTable where ID="& ID
Set ObjRS = objConn.Execute(StrSQL)
else
Response.write "Error in passing ID to SQL"
Response.end
end if
I am no expert but it sounds like you have got some sort of macro or count field within your database that is denying the records deletion.
Your code appears to be fine and as you said, it has worked before.
Have you inserted any new fields in your database that utilize macros or counts?
It might also be worth checking relationships of tables just incase there is something you missed out.
Otherwise I haven't got a clue. : )
Your code appears to be fine and as you said, it has worked before.
Have you inserted any new fields in your database that utilize macros or counts?
It might also be worth checking relationships of tables just incase there is something you missed out.
Otherwise I haven't got a clue. : )
ASKER
my mistake, just made a lil mistake on the QueryString so id was user and vice versa, thanks anyways!
So how do you intend to close this question? Both mine and jitganguly's comment hinted to you that there is something wrong with your QueryString and thus I suggest a split.
hongjun
hongjun
I have had instances where I needed to cast a querystring value to a particular type, because ASP was returning it as some kind of variant.
CStr(request.querystring(" value")
or CInt(request.querystring(" value")
CStr(request.querystring("
or CInt(request.querystring("
Please maintain your open questions:
https://www.experts-exchange.com/questions/20254546/Download-HTML.html
https://www.experts-exchange.com/questions/20180411/Listbox1-Columns.html
https://www.experts-exchange.com/questions/20166816/Keyboard-Lights.html
https://www.experts-exchange.com/questions/20163381/Print-text-to-printer-as-HTML.html
https://www.experts-exchange.com/questions/20123196/Table-calculating.html
https://www.experts-exchange.com/questions/20099958/Databases.html
https://www.experts-exchange.com/questions/20098209/Memo1-Specify.html
https://www.experts-exchange.com/questions/20476242/UPDATE-table.html
https://www.experts-exchange.com/questions/20463499/Show-only-a-few-hits-at-the-time.html
Fritz the Blank
https://www.experts-exchange.com/questions/20254546/Download-HTML.html
https://www.experts-exchange.com/questions/20180411/Listbox1-Columns.html
https://www.experts-exchange.com/questions/20166816/Keyboard-Lights.html
https://www.experts-exchange.com/questions/20163381/Print-text-to-printer-as-HTML.html
https://www.experts-exchange.com/questions/20123196/Table-calculating.html
https://www.experts-exchange.com/questions/20099958/Databases.html
https://www.experts-exchange.com/questions/20098209/Memo1-Specify.html
https://www.experts-exchange.com/questions/20476242/UPDATE-table.html
https://www.experts-exchange.com/questions/20463499/Show-only-a-few-hits-at-the-time.html
Fritz the Blank
You shouldn't be using * for DELETE statements
So your code should be like this:
ID = Request.QueryString("ID")
StrSQL = "DELETE from MyTable where ID="& ID
Set ObjRS = objConn.Execute(StrSQL)
I'm assuming your ID is an integer.
So your code should be like this:
ID = Request.QueryString("ID")
StrSQL = "DELETE from MyTable where ID="& ID
Set ObjRS = objConn.Execute(StrSQL)
I'm assuming your ID is an integer.
TeChNiCh,
You have 10 of the 16 questions you've asked at Experts Exchange still open, dating back to March of 2001. That, to put it mildly, is a horrible grading record.
Part of being a member here is closing your questions. Please take care of these in short order.
https://www.experts-exchange.com/questions/20463499/Show-only-a-few-hits-at-the-time.html
https://www.experts-exchange.com/questions/20476242/UPDATE-table.html
https://www.experts-exchange.com/questions/20494438/Trying-to-delete-a-record.html
https://www.experts-exchange.com/questions/20098209/Memo1-Specify.html
https://www.experts-exchange.com/questions/20099958/Databases.html
https://www.experts-exchange.com/questions/20123196/Table-calculating.html
https://www.experts-exchange.com/questions/20163381/Print-text-to-printer-as-HTML.html
https://www.experts-exchange.com/questions/20166816/Keyboard-Lights.html
https://www.experts-exchange.com/questions/20180411/Listbox1-Columns.html
https://www.experts-exchange.com/questions/20254546/Download-HTML.html
Netminder
EE Admin
You have 10 of the 16 questions you've asked at Experts Exchange still open, dating back to March of 2001. That, to put it mildly, is a horrible grading record.
Part of being a member here is closing your questions. Please take care of these in short order.
https://www.experts-exchange.com/questions/20463499/Show-only-a-few-hits-at-the-time.html
https://www.experts-exchange.com/questions/20476242/UPDATE-table.html
https://www.experts-exchange.com/questions/20494438/Trying-to-delete-a-record.html
https://www.experts-exchange.com/questions/20098209/Memo1-Specify.html
https://www.experts-exchange.com/questions/20099958/Databases.html
https://www.experts-exchange.com/questions/20123196/Table-calculating.html
https://www.experts-exchange.com/questions/20163381/Print-text-to-printer-as-HTML.html
https://www.experts-exchange.com/questions/20166816/Keyboard-Lights.html
https://www.experts-exchange.com/questions/20180411/Listbox1-Columns.html
https://www.experts-exchange.com/questions/20254546/Download-HTML.html
Netminder
EE Admin
Administrative Action - Force Accepted
SpideyMod
Community Support Moderator @Experts Exchange
SpideyMod
Community Support Moderator @Experts Exchange
ID = Request.QueryString("ID")
if not isnumber(ID) or len(ID) > 0 Then
StrSQL = "DELETE from MyTable where ID="& ID
Set ObjRS = objConn.Execute(StrSQL)
else
Response.write "Error in passing ID to SQL"
Response.end
end if