Populate Datagrid from a Stored Procedure

Discussion in 'ASP .Net Datagrid Control' started by Scott D, Jul 1, 2004.

  1. Scott D

    Scott D Guest

    I am trying to fill datagrid from a stored procedure using the
    following code:



    Public Sub dgTicketsFill2()
    I have removed a of my connString info for posting purposes
    Dim connString As String = "server=;uid=;pwd=;Initial
    Catalog="
    Dim conn As SqlConnection = New SqlConnection(connString)
    Dim cmd As SqlCommand = New SqlCommand("~Stored Procedure
    Name~", conn)
    cmd.CommandType = CommandType.StoredProcedure

    Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
    Dim ds As DataSet = New DataSet

    da.Fill(ds, "ViewOpenTickets")
    Me.dgOpenTickets.DataSource =
    ds.Tables("ViewOpenTickets").DefaultView
    Me.dgOpenTickets.DataBind()
    End Sub

    I receieve the following error:

    Object reference not set to an instance of an object.

    I can fill this same datagrid with no problems if I use a SELECT
    statement directly to fill the dataset.
     
    Scott D, Jul 1, 2004
    #1
    1. Advertising

  2. Scott D

    Scott D Guest

    This has been resolved. I was dropping the table at the end of the
    stored procedure there by producing no results for my dataset.
     
    Scott D, Jul 6, 2004
    #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. Mo
    Replies:
    1
    Views:
    4,195
    FFlannery
    Jan 30, 2004
  2. =?Utf-8?B?SklNLkgu?=

    Q: populate ddl from stored procedure

    =?Utf-8?B?SklNLkgu?=, Apr 11, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    400
    Craig Deelsnyder
    Apr 11, 2005
  3. Mike P
    Replies:
    0
    Views:
    3,311
    Mike P
    Jun 19, 2006
  4. Machelle Chandler

    populate datagrid with stored procedure w/parameter

    Machelle Chandler, Oct 16, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    4
    Views:
    174
    Machelle Chandler
    Oct 17, 2003
  5. Enjoy Life
    Replies:
    2
    Views:
    280
    Roland Hall
    Feb 23, 2005
Loading...

Share This Page