Tuesday, March 27, 2012

Executing more than one query

Hi,

How to execute more than one query consecutively in SqlDataSource like the picture shown below.

you could put multiple statements together by seperating them with a semicolon:

insert blah into blah; insert blah2 into blah2; insert somethingelse into somewhereelse;

|||

Hello my friend,

You should be able to put 1 INSERT/UPDATE/DELETE statement one after the other. Another approach would be to specify a stored procedure to do the INSERT/UPDATE/DELETE and then within the stored procedure have multiple INSERT/UPDATE/DELETE commands. Below is an example SQL script that will create a stored procedure: -

CREATE PROCEDURE usp_InsertClientWithPreference
(
@.ClientName AS VARCHAR(250),
@.ContactNumber AS VARCHAR(20),
@.VacationCountry AS VARCHAR(250)
)

AS

INSERT INTO tblClient (ClientName, ContactNumber)
VALUES (@.ClientName, @.ContactNumber)

UPDATE tblFavourites SET Total = (Total + 1)
WHERE Country = @.VacationCountry


RETURN

Kind regards

Scotty

|||

Thanks sirs..You showed your best quality as always you showSmile

Regards..

No comments:

Post a Comment