Hello everyone. I am using VS/VB 08 together with access 07 for my project. I am trying to fill my datagridview using a custom SQL query where the "where" criteria is altered to accept the column name from the selection of the user. When a user clicks on a column in the datagrid I want that column to be represented in the query. This is what I have but is not working. Is this possible by the way?
U can see that 'search1' get its data from a textbox which represents the current selection of column the user has made.
VB.NET:
Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\Serverjde\jde\Database0.accdb;Persist Security Info=False;")
Dim search1 As String = Me.TextBox3.Text
Dim search2 As String = Me.TextBox1.Text
Try
conn.Open()
Dim da As OleDbDataAdapter = New OleDbDataAdapter("Select * from AllServices where 'search1' = '" & search2 & "'", conn)
Dim ds As Database2DataSet = New Database2DataSet
' fill dataset
da.Fill(ds, "AllServices")
' Attach DataSet to DataGrid
AllServicesDataGridView.DataSource = ds.Tables("AllServices")
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
U can see that 'search1' get its data from a textbox which represents the current selection of column the user has made.