We help IT Professionals succeed at work.
Get Started

How manually fill a DataGridView from a SQL Express table?

EYoung
EYoung asked
on
1,029 Views
Last Modified: 2012-05-06
I am new to VB.net and have written an application that reads a SQL Server 2008 Express table and am trying to use the returned records to manually fill a DataGridView.

I have added a DataGridView (dgvShoot_Events) to a form.  Its Data Source is set to "None" and I have defined its four fields with the same names as in the Express table.

The SQL Server Express Stored Procedure works as I have executed it manually in SQL Express.

The code below looks like it is working but nothing shows up in the DataGridView.

What am I doing wrong?  Thanks, EYoung
Private Sub srLoad_dgvShoot_Events()
        Me.Cursor = Cursors.WaitCursor
 
        Using connExpress As New SqlConnection(My.Settings.SqlConnection)
            Dim cmdExpress As SqlCommand = New SqlCommand
            cmdExpress.Connection = connExpress
            cmdExpress.CommandText = "Get_Shoot_Events_One_Shoot"
            cmdExpress.CommandType = CommandType.StoredProcedure
 
            Dim mParameter As SqlParameter = New SqlParameter("@mShoot_Name_mKey", "'" & mShoot_Name_mKey & "'")
            mParameter.Direction = ParameterDirection.Input
            mParameter.DbType = DbType.String
 
            cmdExpress.Parameters.Add(mParameter)
 
            Dim daExpress As SqlDataAdapter = New SqlDataAdapter(cmdExpress)
 
            Dim dsExpress As DataSet = New DataSet("Shoot_Event_Types")
 
            daExpress.Fill(dsExpress)
 
            dgvShoot_Events.DataSource = dsExpress.Tables(0)
 
        End Using
 
        Me.Cursor = Cursors.Default
    End Sub

Open in new window

Comment
Watch Question
IT Pro/Developer
CERTIFIED EXPERT
Top Expert 2008
Commented:
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE