Display data in DGV

jamie_pattison

Well-known member
Joined
Sep 9, 2008
Messages
116
Programming Experience
Beginner
Im trying to display this data in a data grid view. This is the code

VB.NET:
        Dim conStr As String = "server=server; database=database; userid=bob; password=password;"
        Dim selectCmd As String = "SELECT * FROM CUSTOMERS"
        Dim conn As SqlConnection = New SqlConnection(conStr)

        Dim da As New SqlDataAdapter(selectCmd, conStr)
        Dim ds As New DataSet

        da.Fill(ds)

        conn.Open()

        DataGridView1.DataSource = ds
        DataGridView1.Show()

        conn.Close()

It doesnt seem to display but im sure the database has records and the select query is correct. Im also sure the connection to the database is working. Im not sure what im doing wrong here?

Thanks
 
Please see the DW2 link in my signature for advice on how to do data access properly. Read the section on Creaing a Simple Data App
 
Back
Top