Display and Insert SQL queryString,

Posted on 2005-05-05
Last Modified: 2008-01-09
Hello Experts,

I have two statements and wish to only have one as when ran with two they counter act each other and the info is added to the table but not displayed:

Displays the info i want:  

queryString = "select * from tCart where OrderNbr = " + OrderNbHS;

Copies the info i want:    

queryString = "INSERT INTO [tOrderDetail] SELECT [pcode],[qty],[OrderNbr] FROM [tCart] WHERE OrderNbr = " + OrderNbHS;

Thank You!
Question by:henrym01
    LVL 8

    Accepted Solution

    Are you looking for one SQL statement which will insert and select at one go:
    This isnt possible with a SQL statemtent, but can be obviously done by a stored procedure:

    Call the stored procedure from c# using Command.Execute to give a datareader which will have the details to display

    stored procedure will have two statement one for inser and the other for select - see below link for more details

    LVL 7

    Expert Comment

    i am not getting ur question...

    In the above case ...u cannot have two statements combine...

    but u can use the insert statement first and then select so u can get the inserted data displayed.


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now