#1
  1. No Profile Picture
    Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Feb 2008
    Posts
    790
    Rep Power
    30

    Delete and Insert at same time


    This code seems to work, but is this fundamentally correct or is there a better way of doing both a delete and an insert to follow:

    Code:
    sql_1= "Delete From Table1 Where CustomerID = "&CustomerID&" and Productid = "&Productid&" "
        	   
    sql_2 = "insert into Table1 (ProductID,CustomerID,NewDate) values(" &_ 
               
            "'" & NewProductID & "'," &_
            "'" & CustomerID & "'," &_  
            "'" & NewDate & "')" 
    
    objConn.Execute(sql_1)
    objConn.Execute(sql_2)
  2. #2
  3. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,584
    Rep Power
    278
    this code should work. I'm not sure what you trying to archive, and what is your table structure, but nothing wrong with that code
    GK
    __________________________________________________ _____
    if you found this post is useful click Give Rep button (bottom side on this reply ) and agree
  4. #3
  5. No Profile Picture
    Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Feb 2008
    Posts
    790
    Rep Power
    30
    My main concern is if it's ok to first DELETE (which is what I want) and then INSERT. I am basically making a substitute. Like I said, it works in trial but wasn't sure if there is a fundamentally better way of doing that.

    Thanks for looking at that, I appreciate it.

Similar Threads

  1. Insert to then delete sql question
    By jesushax in forum ASP Development
    Replies: 4
    Last Post: January 4th, 2008, 07:35 AM
  2. Insert Into and Delete from Database
    By maggs in forum ASP Development
    Replies: 7
    Last Post: November 15th, 2007, 08:15 AM
  3. Insert and delete of the same row
    By dhaneshrs in forum .NET Development
    Replies: 0
    Last Post: August 16th, 2007, 12:42 AM
  4. Insert, Update, Delete statements
    By admol in forum .NET Development
    Replies: 2
    Last Post: February 20th, 2007, 08:01 PM
  5. update delete insert with dataset
    By Steve Schofield in forum SQL Development
    Replies: 0
    Last Post: March 7th, 2002, 03:04 PM

IMN logo majestic logo threadwatch logo seochat tools logo