I am pretty sure that the VB.NET code is right but I am sure my SQL statements are completely wrong ..can anyone help me figure out my mistakes and as to how the SQL statements need to be framed to get the results correctly from the Access Database ?
Thansk,
Kukki
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim con As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\bashkark\Desktop\Copy of USERS.mdb")
Dim cmd1 As New OleDbCommand
con.Open()
If (CheckBox1.Checked = True) Then
cmd1 = New OleDbCommand("select * from table1 where RAM ='< 2 GB'", con)
End If
If (CheckBox2.Checked = True) Then
cmd1 = New OleDbCommand("select * from table1 where RAM is between '2 GB' and RAM is between '3 GB'", con)
End If
If (CheckBox3.Checked = True) Then
cmd1 = New OleDbCommand("select * from table1 where RAM is between '2 GB' and RAM is between '3.25 GB'", con)
End If
If (CheckBox4.Checked) Then
cmd1 = New OleDbCommand("select * from table1 where RAM is between '1 GB' and RAM is between '3 GB'", con)
End If
If (CheckBox5.Checked = True) Then
cmd1 = New OleDbCommand("select * from table1 where RAM is between '3 GB' and RAM is between '8 GB'", con)
End If
If (CheckBox6.Checked = True) Then
cmd1 = New OleDbCommand("select * from table1 where RAM is between '3.25 GB' and RAM is between '8 GB'", con)
End If
If (CheckBox7.Checked = True) Then
cmd1 = New OleDbCommand("Select * from table1 where RAM is between '2 GB' and RAM is between '8 GB'", con)
End If
If (CheckBox8.Checked = True) Then
cmd1 = New OleDbCommand("select * from table1 where RAM is between '2.98 GB' and RAM is between '8 GB'", con)
End If
Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd1)
Try
Dim ds As DataSet = New DataSet()
da.Fill(ds, "table1")
DataGridView1.DataSource = ds.Tables("table1").DefaultView
Finally
con.Close()
cmd1 = Nothing
da.Dispose()
con.Dispose()
End Try
End Sub