when I hit click i get a blank table in my datagridview with no values in it! why is that ?

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.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 (RadioButton1.Checked = True) Then

cmd1 = New OleDbCommand("select * from table1 where GRAPHICSCARD='NVIDIA *'", con)

End If

If (RadioButton2.Checked = True) Then

cmd1 = New OleDbCommand("select * from table1 where GRAPHICSCARD='3D*'", 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

Hi Kavitha, Please clearly specify what you trying to do.

hi KSG:

My choice of radiobutton should get execute a a query. if i chose the first radio button..i want a query with all graphicscard startting with nvidia which is why i have used nvidia* and the same pplies to the 2nd radio button...

Yes Now I Understand.This Query is working when Exactly the GraphicsCARD is NVIDIA*, because u specified = operator. When you query to the pattern (like NVIDIA*) you should use Like Operator. Also My advise use (code) tags for Code Indentation.
Example for Like operator

SELECT * FROM table1 WHERE GRAPHICSCARD LIKE 'NVIDIA*'

Hi KSG:

I got it right,.. All i had to do was use 'NVIDIA%'..


my code..for data entry..it was working fine when i had all of them as textboxes.. i get no errors but data entry does not take place in my Access atall!

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Try

Dim con As OleDb.OleDbConnection

Dim cmd As OleDbCommand

Dim icount As Integer

Dim str As String

con = New OleDbConnection("provider=microsoft.jet.OLEDB.4.0; data source=C:\Documents and Settings\bashkark\Desktop\Copy of USERS.mdb")

con.Open()

str = "insert into table1 values('" & TextBox1.Text & "', '" & TextBox2.Text & "','" & TextBox3.Text & "', '" & ComboBox1.Text & "', '" & ComboBox2.Text & "','" & ComboBox3.Text & "', '" & ComboBox4.Text & "', '" & ComboBox5.Text & "','" & ComboBox6.Text & "','" & ComboBox7.Text & "','" & ComboBox8.Text & "','" & ComboBox9.Text & "', '" & ComboBox10.Text & "', '" & ComboBox11.Text & "', '" & ComboBox12.Text & "')"

cmd = New OleDbCommand(str, con)

icount = cmd.ExecuteNonQuery

MessageBox.Show(icount)

con.Close()

Catch

End Try

End Su
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.