sql server 2008 - execute stored procedure in classic asp and return values -


i need call asp page stored procedure have in sql 2008 , pass 2 values , @ end return count of 2 variables.

this stored procedure have:

        /****** studatatab******/ create procedure stdntreconciledups @newstdnt int = null, @oldstdnt int = null output --use zldp01rd; --count = 9 rows select count (*) studata.dbo.studatatab  stdnt = @newstdnt;  -- count = 576 rows select count(*) studata.dbo.studatatab  stdnt = @oldstdnt;  -- select duplicate keys new student# count = 3 rows select a.stdnt,a.crs,a.crs_vrsn,a.qstn,a.scr     studata.dbo.studatataba, studata.dbo.studatatabb         a.stdnt = @newstdnt         , b.stdnt = @oldstdnt         , a.crs = b.crs         , a.crs_vrsn=b.crs_vrsn         , a.qstn=b.qstn         , a.scr=b.scr   -- select duplicate keys new student# count = 3 rows select count (*)      studata.dbo.studatataba      exists (select 1 studata.dbo.studatatabb                     a.stdnt = @newstdnt                       , b.stdnt = @oldstdnt                       , a.crs = b.crs                       , a.crs_vrsn=b.crs_vrsn                       , a.qstn=b.qstn                       , a.scr=b.scr );   -- delete duplicate keys new student# 3 rows deleted  student_cte     (select a.*      studata.dbo.studatataba      exists (select 1 studata.dbo.studatatabb                     a.stdnt = @newstdnt                       , b.stdnt = @oldstdnt                       , a.crs = b.crs                       , a.crs_vrsn=b.crs_vrsn                       , a.qstn=b.qstn                       , a.scr=b.scr )) delete student_cte;  --convert student #10826 history records student #123196, should update 579 rows update studata.dbo.studatatab  set stdnt = @newstdnt, lstupdt_user_id_cd = 'dfern', lstupdt_ts = getdate()  stdnt = @oldstdnt;  -- count= 582 select count(*) studata.dbo.studatatab  stdnt = @newstdnt;  -- count= 0 select count(*) studata.dbo.studatatab  stdnt = @oldstdnt; go 

i want insert code in if argument calls stdntreconciledups , pass values of keepstdnt , removestdnt

    dim dbconn  ' connection object if request.form("action") = "go!"   endif 

if got meaning...then below:

 sqlconnection con = new sqlconnection("data source=  ; initial catalog= northwind ; user id=  ; password=  '");          con.open(); 

after creating sqlconnection create storedprocedure below:

        create procedure regionupdate (@regionid integer,@regiondescription nchar(50))         set nocount off         update region         set regiondescription = @regiondescription 

create sqlcommand object parameters name of stored procedure executed , connection object con command sent execution.

        sqlcommand command = new sqlcommand("regionupdate",con); 

change command objects commandtype property stored procedure.

    command.commandtype = commandtype.storedprocedure; 

add parameters command object using parameters collection , sqlparameter class.

        command.parameters.add(new sqlparameter("@regionid",sqldbtype.int,0,"regionid"));          command.parameters.add(new sqlparameter("@regiondescription",sqldbtype.nchar,50,"regiondescription")); 

specify values of parameters using value property of parameters

        command.parameters[0].value=4;          command.parameters[1].value="southeast"; 

excecute stored procedure using executenonquery method returns number of rows effected stored procedure.

         int i=command.executenonquery(); 

the code above right way...you can replace @keepstdnt , @removestdnt instead of @regionid , @regiondescription...i have used myself...if wanna more help...tell then


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -