If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > delete and insert using variables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-01-11, 05:00
AndyJay AndyJay is offline
Registered User
 
Join Date: Feb 2008
Posts: 68
delete and insert using variables

Hi all..
Can anyone see what the problem is with this delete and insert command?
I'm using classic ASP and MS SQL.

Code:
ClientIDStrg =Request.QueryString("ClientIDStrg")
Code:
delete from RelatedProducts where ProductID=" & ProductID & "AND ClientID=" & ClientIDStrg & "or RelatedProductID=" & ProductID & "AND ClientID=" & ClientIDStrg
Code:
insert into RelatedProducts (ProductID,RelatedProductID,ClientID) values (" & ProductID & "," & arr(i) & "," & ClientIDStrg & ")"
If i use 1 inplace of the ClientIDStrg variable, all works fine.
The productID varailbe uses the same method and that works fine.

The database uses int for both fields.

The error i get is:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'or'.

Thanks in advance
Andy (scratching head)
Reply With Quote
  #2 (permalink)  
Old 09-01-11, 15:51
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
Lookup prepared statements/commands, particularly in the context of sql injection. The approach you're taking is both cumbersome to write and extremely dangerous when exposed to a malicious user.
__________________
oh yeah... documentation... I have heard of that.

*** What Do You Want In The MS Access Forum? ***
Reply With Quote
  #3 (permalink)  
Old 09-01-11, 19:53
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Pretty sure your delete statment will get upset due to lack of spaces between your variables and your AND and OR clauses...
Reply With Quote
  #4 (permalink)  
Old 09-28-11, 21:01
paultech paultech is offline
Registered User
 
Join Date: Sep 2011
Posts: 71
Lightbulb Your Problem Solution ,as i thought

hello just do these modifications on your code ,and reply me:


1-At our Dot net code ,First check query string value to be insure not null

2-convert to int using ,int.parse(querystring.ToString())

[COLOR="rgb(160, 82, 45)"]Thanks[/COLOR]

Last edited by paultech; 09-28-11 at 21:02. Reason: update
Reply With Quote
  #5 (permalink)  
Old 10-27-11, 09:34
paultech paultech is offline
Registered User
 
Join Date: Sep 2011
Posts: 71
Hello , I thought that you should use single quotation instead of double quotation
Try please and tell me your results.
thanks
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On