| 发表于:2007-01-12 16:01:16 楼主 |
本人初学,我要得到存储过程返回的记录,大家来帮看看! 本人存储过程如下; create procedure p_returnmobliephone @applicationid int, @mobilephone nvarchar output as declare @applicationdepartment nvarchar declare @departmenttable nvarchar declare @functionlevel smallint declare @shiptype nvarchar select @applicationdepartment=(select applicationdepartment from p_application where id=@applicationid) select @departmenttable=(select departmenttable from department where departmentid=@applicationdepartment) if (@departmenttable= 'stationinfo ') begin select @functionlevel= '6 ' end if (@departmenttable= 'shipinfo ') begin select @shiptype=(select shiptype from shipinfo where shipid=@applicationdepartment) if (@shiptype= 'shiptype001 ') select @functionlevel= '4 ' if (@shiptype= 'shiptype002 ') select @functionlevel= '5 ' if (@shiptype= 'shiptype003 ') select @functionlevel= '5 ' end select @mobilephone=(select mobilephone from employee where functionlevel=@functionlevel) go 我要获取@mobilephone参数的返回值,是这么写吗? sqlconnection conn=new sqlconnection(configurationsettings.appsettings[ "my_connstr "]); conn.open(); sqlcommand sqlcmd=new sqlcommand(); sqlparameter my_parameter=new sqlparameter( "@applicationid ",sqldbtype.int); my_parameter.value=2; sqlcmd.parameters.add(my_parameter); sqlparameter my_return=new sqlparameter( "@mobilephone ",sqldbtype.nvarchar,20); my_return.direction=parameterdirection.output; my_return.value=null; sqlcmd.parameters.add(my_return); sqlcmd.connection=conn; sqlcmd.commandtext= "p_returnmobliephone "; sqlcmd.commandtype=commandtype.storedprocedure; sqlcmd.EXECutenonquery(); conn.close(); this.response.write(sqlcmd.parameters[ "@mobilephone "].value.tostring()); 为什么this.response.write(sqlcmd.parameters[ "@mobilephone "].value.tostring());取不到值,数据库里面是有值的 |
|
|
|
|