If I want to make a SELECT query on a database through ADO, how can I do that? Do I use the ADODB.Recordset or ADODB.Command? Also how can I search through the records returned and only return the value of a certain field from the records? For those of you who know PHP and MySQL, what will be the vb equivalent of the following code using a Microsoft Access database:
$result=mysql_query("SELECT * FROM mytable WHERE myfield='data'");
For those of you who don't know PHP, the above code is making a SQL query and selecting all the fields of a table called 'mytable' where the value of a field called 'myfield' is 'data'. After that it goes through each record returned, and stores the value of the field 'some_field' from that record in an array. At the end of the code it returns the array containing the values of the 'my_field' from each result record.
What i think your trying to do is get the results returned in a recordset,
Store your procedure in a ADODB command and return the values into a recordset
'Execute A SQL Command
Set cmdCheck = New ADODB.Command
Set cmdCheck.ActiveConnection = conSQL
cmdCheck.CommandText = "SELECT * FROM mytable WHERE myfield=" & Chr(34) & "data" & Chr(34) & ";"
'Execute the SQL Command and store in a recordset
Set rstCheck = New ADODB.Recordset
Set rstCheck = cmdCheck.Execute
conSQL is the Connection that has already been set up
You can then work with the recordset to do what you want,
Look into things such as find and move to traverse your recordset,