Notices

Great community. Great ideas.

Welcome to ASP/Free, a community dedicated to helping beginners and professionals alike in improving their knowledge of Microsoft's development and administration technologies. Sign up today to gain access to the combined insight of tens of thousands of members.

Thread: Delete and Insert at same time

Results 1 to 3 of 3
Share This Thread →
  1. #1
    phoenixaz is offline Contributing User
    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
    gk53's Avatar
    gk53 is offline Contributing User
    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,535
    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

  3. #3
    phoenixaz is offline Contributing User
    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.

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

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

ASP Free Advertisers and Affiliates