Results 1 to 8 of 8

Thread: Consuming SPROC output parameter in DAL??

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    120

    Consuming SPROC output parameter in DAL??

    I want to consume an output parameter from a stored procedure. I am getting pretty comfortable using the DAL that there is very little code to work with to actually consume the output parameter.

    I was hoping it would show up in the ObjectDataSource / Gridview control as an available value but no such luck. I notice when I edit my Business Object in design view, choose configure DataSource, click next twice to get to define parameters, I have a numberRows parameter (along with selectDate, selectCountr) that has a Parameter Source set to none. In the default Value aree (after clicking advanced properties) I selected down to Direction and changed the value to Output. But it does now seem to stick..

    Here is the working stored procedure:

    ALTER PROCEDURE dbo.ap_Select_ModelRequests_RequestDateTime

    /* Input or Output Parameters */
    /* Note that if you declare a parameter for OUTPUT, it can still be used to accept values. */
    /* as is this procedure will very well expect a value for @numberRows */
    @selectDate datetime
    ,@selectCountry int
    ,@numberRows int OUTPUT

    AS

    SELECT DISTINCT configname FROM ModelRequests JOIN
    CC_host.dbo.usr_c As t2 ON
    t2.user_id = ModelRequests.username JOIN
    Countries ON
    Countries.Country_Short = t2.country
    WHERE RequestDateTime >= @selectDate and RequestDateTime < dateadd(dd,1, @selectDate)
    AND configname <> '' AND interfacename LIKE '%DOWNLOAD%' AND result = 0 AND Country_ID = @selectCountry
    ORDER BY configname

    /* @@ROWCOUNT returns the number of rows that are affected by the last statement. */
    /* Return a scalar value of the number of rows using an output parameter. */
    SET @numberRows = @@RowCount
    -- RETURN ??

    GO

    How exactly will I consume this? In the code behind? or in the .xsd source code view? Or some other way.

    Using DAL my code behind is 100% eliminated and not needed.

    ' The Below code is no longer needed now that we can create and use

    ' Data Access Layer (DAL) Objects to query the database

    '----------------------------------------------------------------------------------------

    'Protected Sub BtnGetModels_Click1(ByVal sender As Object, ByVal e As System.EventArgs)

    'Dim dateEntered As String = TxtDate.Text

    'Dim selectCountry As String = CountryList.SelectedValue

    'Dim con As New SqlClient.SqlConnection

    'con.ConnectionString = "Data Source=;Initial Catalog=New_Products;Persist Security Info=True;User ID=ad;Password=wd"

    'Dim myCommand As New SqlClient.SqlCommand

    'myCommand.CommandText = "ap_Select_ModelRequests_RequestDateTime"

    'myCommand.CommandType = CommandType.StoredProcedure

    'myCommand.Parameters.AddWithValue("@selectDate", dateEntered)

    'myCommand.Parameters.AddWithValue("@selectCountry", CInt(selectCountry))

    'myCommand.Connection = con

    'con.Open()

    'Dim reader As SqlDataReader = myCommand.ExecuteReader()

    'Dim rowCount As Integer = reader.RecordsAffected

    'numberParts.Text = rowCount.ToString

    'con.Close()

    'End Sub

    Is what I need to do possible by using only a DAL?

    Help appreciated
    Last edited by Acuffdl; Sep 11th, 2007 at 07:55 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width