Query Problem RRS feed

  • Question

  • I'm trying to get a DataGridView to display the Venue_Name based on information in a separate Label titled "VenueIDValue".
    The grid is returning every venue in the table, but I only want it to return the one that matches the ID in the "VenueIDValue" label. Can someone help please?

    Here is my code:

    Imports System.Data.OleDB
    Public Class Form1
        Dim myConnection As New OleDbConnection

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Michael\Desktop\CTB Project\CTB Project\CTB Project\CTB Database.mdb"
            Dim myDataAdapter As New OleDbDataAdapter("Select Venue_Name From Concert_T Where 'Venue_ID = Purchase.VenueIDValue.Text'", myConnection)
            Dim myDataSet As New DataSet
            myDataAdapter.Fill(myDataSet, "Concert_T")
            DataGridView1.DataSource = myDataSet.Tables("Concert_T")
        End Sub
    End Class

    I'm getting an error on the
    myDataAdapter.Fill(myDataSet, "Concert_T") line.

    Can someone tell my what my problem is please? I'm a total novice trying to make something work.
    Sunday, December 7, 2008 7:20 AM