title: Populate DataGridView from a Stored Procedure
body: <p>Using SQL Server 2008 I created a Stored Procedure called MyStoreProc and it runs fine from the Management Tools.</p>
  
  <p>In VB.Net 2008 I created a new dataset and a new TableAdaptor.  In this table adapter I created a new Query called FillByGrid and selected the Stored Procedure.  Previewed data and it previewed correctly.</p>
  
  <p>On a form I created DataGridView and selected the Table Adapter from the dataset.</p>
  
  <p>I ran the app and no data is shown.  Visual Studio autocreated the code below and I changed it to select the the Query I just created:</p>
  
  <pre><code>Me.MyTableAdapter.FillByGrid(Me.MyDataset.MyTableAdaptor)
  </code></pre>
  
  <p>No data is shown on the grid so I tried the manual approach:</p>
  
  <pre><code>' Create the dataset
  Dim da As New SqlDataAdapter, ds As New DataSet
  Dim conn As New SqlConnection
  
  conn.ConnectionString = opsData.DBConn.ConnectionString
  da.SelectCommand = New SqlCommand
  da.SelectCommand.Connection = conn
  da.SelectCommand.CommandType = CommandType.StoredProcedure
  da.SelectCommand.CommandText = "dbo.MyStoreProc"
  da.Fill(ds, "tbl1")
  DataGridView2.DataSource = ds.Tables("tbl1")
  </code></pre>
  
  <p>Still no data shown.  However stepping through the I can see that the connection is open, and "da.Fill(ds, "tbl1")" takes a little bit of time as it is running the Stored Procedure and ds table has the correct number of rows and columns.  Its just not being shown on the datagrid.</p>
  
  <p>Creating another table adapter in the dataset and returning data from a database table using a standard select * from table command display in the datagridview fine.</p>
  
  <p>Does anyone have any suggestions?</p>
  
  <p>Thank you</p>