extract Sproc output Parm from dataset?!

darenkov

Member
Joined
Jan 28, 2005
Messages
7
Location
Perth Australia
Hi,

I have created a dataset which is populated with the results from my Stored Procedure and then bound to my datalist. Everything works fine but I am not sure how to get the Ouput Paramater back from my SPROC through my dataset or otherwise. I know it can be done with the command.executenonquery method but I am not using that as I am just using the fill method of the dataset to get my results. Is there anyway I can pull this out through my dataset or a different method (other than command.executenonquery ?

Here is the relevant block of code containing the name of the output parameter:

------------------------------------------------------------
cmd.Parameters.Add("@FullCount", SqlDbType.Int)
cmd.Parameters("@FullCount").Direction = ParameterDirection.Output

Dim adapter As New SqlDataAdapter(cmd)
Dim ds As New DataSet()

adapter.Fill(ds)

ListResults.DataSource = ds.Tables(0).DefaultView
ListResults.DataBind()

How can I get the @FullCount parameter into a variable?

cheers
 
Code:
cmd.Parameters.Add("@FullCount", SqlDbType.Int)
cmd.Parameters("@FullCount").Direction = ParameterDirection.Output

Dim adapter As New SqlDataAdapter(cmd)
Dim ds As New DataSet()

adapter.Fill(ds) 
Dim i as integer = cmd.Parameters("@FullCount").Value

should do it.
 
Back
Top