Populate Datagrid from a Stored Procedure

S

Scott D

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.
 
S

Scott D

This has been resolved. I was dropping the table at the end of the
stored procedure there by producing no results for my dataset.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top