hi.........i'm new to vb.net i have to make a project where the user enters a s.no in a text box and clicks a button and then the result of search is to be displayed on the data grid............but the problem is that instead of showing only that particular result set it is showing the entire database...........I'm using visual studio 2005 with ms access 2007.........this is the code that i' using
can someone plz rectify my problem...................
- Imports System.Data.OleDb
- Public Class sno
- Dim ds As DataSet = New DataSet()
- Private Sub sno_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- 'TODO: This line of code loads data into the 'RecordDataSet._property' table. You can move, or remove it, as needed.
- Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\saakshi.ABC\My Documents\Visual Studio 2005\Projects\record.mdb")
- Dim cmd As OleDbCommand = New OleDbCommand("Select * FROM property", con)
- con.Open()
- Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
- Dim myDataSet As DataSet = New DataSet()
- myDA.Fill(myDataSet, "property")
- DataGridView1.DataSource = myDataSet.Tables("property").DefaultView
- con = Nothing
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim con As New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\saakshi.ABC\My Documents\Visual Studio 2005\Projects\record.mdb")
- Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM property", con)
- con.Open()
- Dim sdr As OleDbDataReader = cmd.ExecuteReader()
- While sdr.Read = True
- MessageBox.Show(sdr.Item("sno"))
- End While
- con = Nothing
- End Sub
- End Class
- 1 view