Passing a Dataset from a function in a class

Discussion in 'ASP .Net' started by Daren Hawes, May 11, 2005.

  1. Daren Hawes

    Daren Hawes Guest

    Hi, I have a class called Jobs. In that class is the function below..

    Public Function GetJobTitle(ByVal Job_Title_ID As Integer, ByVal Company_ID
    As Integer) As DataSet
    ' Setup the Stored Procedure
    Dim SqlCommand As New SqlCommand
    Dim SqlConnection As New SqlConnection(DataLayer.ConnectionString)
    Try
    SqlCommand.CommandText = "dbo.DeleteJobTitle"
    SqlCommand.CommandType = System.Data.CommandType.StoredProcedure
    SqlCommand.Connection = SqlConnection
    ' Load the Parameters
    SqlCommand.Parameters.Add(New
    System.Data.SqlClient.SqlParameter("RETURN_VALUE",
    System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
    False, CType(0, Byte), CType(0, Byte), "",
    System.Data.DataRowVersion.Current, Nothing))
    SqlCommand.Parameters.Add(New
    System.Data.SqlClient.SqlParameter("@Job_Title_ID",
    System.Data.SqlDbType.Int, 4)).Value = Job_Title_ID
    SqlCommand.Parameters.Add(New
    System.Data.SqlClient.SqlParameter("@Company_ID", System.Data.SqlDbType.Int,
    4)).Value = Company_ID
    ' Fire the Procedure
    SqlConnection.Open()
    ' Create a dataset
    Dim da As SqlDataAdapter = New SqlDataAdapter
    da.SelectCommand = SqlCommand
    Dim ds As New DataSet
    da.Fill(ds, "JobTitle")
    Return ds
    Catch ex As Exception
    Throw New Exception(ex.ToString)
    Finally
    SqlConnection.Close()
    End Try
    End Function

    I now have a web form called Default.aspx

    How can I poplulate a Datagrid or Select box from the above function?

    Datagrid1.Datasource = jobs.GetJobTitle(1,1) ???

    Please help

    Thanks Daren
     
    Daren Hawes, May 11, 2005
    #1
    1. Advertising

  2. Daren Hawes

    Lucas Tam Guest

    "Daren Hawes" <> wrote in
    news::

    >
    > I now have a web form called Default.aspx
    >
    > How can I poplulate a Datagrid or Select box from the above function?
    >
    > Datagrid1.Datasource = jobs.GetJobTitle(1,1) ???


    Yes exactly - but just remember to call Datagrid1.databind.

    --
    Lucas Tam ()
    Please delete "REMOVE" from the e-mail address when replying.
    http://members.ebay.com/aboutme/coolspot18/
     
    Lucas Tam, May 11, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nedu N
    Replies:
    1
    Views:
    1,801
    Chris Taylor
    Oct 31, 2003
  2. JimO

    DataSet and dataSet

    JimO, Mar 1, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    525
    Mary Chipman [MSFT]
    Mar 8, 2006
  3. Joseph D. DeJohn

    DataSet to DataSet

    Joseph D. DeJohn, Aug 4, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    400
  4. E11
    Replies:
    1
    Views:
    4,786
    Thomas Weidenfeller
    Oct 12, 2005
  5. James Vanns
    Replies:
    7
    Views:
    7,046
    Evan Carew
    Jan 21, 2004
Loading...

Share This Page