Search for primary key data using a button in ADO

Does anyone know how to search a primary key data using a button so that to display out the row of data in the access
when u click the search button it will auto search the primary key data n display out the rows of data for you...
[240 byte] By [AndySim1983] at [2007-11-20 0:39:52]
# 1 Re: Search for primary key data using a button in ADO
Find method on the Recordset to locate a record based on a search string
strCriteria = "PrimaryColName = 2"
rsCustomers.Find strCriteria
Do While Not rsCustomers.EOF
rsCustomers.Find strCriteria, 1
Loop
aniskhan at 2007-11-10 3:30:20 >
# 2 Re: Search for primary key data using a button in ADO
u can also use Open method of recordSet for retrieving data from your database.
Dim strSQL As String
Dim rsCustomers As ADODB.Recordset

strSQL = "SELECT * FROM myTable WHERE PrimaryColName=3"

rsCustomers.Open strSQL, cnDatabase, adOpenStatic
'loop through the results of your query
Do While Not rsCustomers.EOF
'use /display the fields
rsCustomers.MoveNext
Loop
aniskhan at 2007-11-10 3:31:21 >
# 3 Re: Search for primary key data using a button in ADO
as u are in ADO.net Forum so u can do it in ADO.Net
Dim conn As sqlConnection
Dim cmd As sqlCommand
Dim sSQL As String
Dim ds As DataSet

conn = New SqlConnection("Data Source=Aniskhan;initial catalog=Northwind;ed security=SSPI")

Dim adapter As New sqlDataAdapter

sSQL = "SELECT * FROM myTable WHERE PrimaryCol=" & Integer.parse(me.TextBox1.text)
cmd = New sqlCommand(sSQL, conn)

adapter.SelectCommand = cmd
ds = New DataSet("myTable")
conn.Open()
adapter.Fill(ds)
conn.Close()
aniskhan at 2007-11-10 3:32:23 >