You can open a recordset ( a group of rows which fit your "seek"Quote:>Even thought there is no strict "AB" value in that column, it would put the cursor on column 4 as it being the first closest value to my seek string. Then I could cycle through the records after that looking for one that fit my other criteria. Is there a way to do this with SQL Server and ODBC that won't take forever (like cycling through the records manually until I get where I want)?? Thanks
criteria) as follows:
select value from table where value like 'AB%' order by value
You can then cycle through the results (recordset) as you would in
However, the most efficient way is to build your conditions into the
SQL statement itself rather than stepping through each row. I usually
go through a process in my program where I am building the select
statement with the different conditions I am looking for. For example,
dim strSql as string, strWhere as string
dim rs as new ADODB.recordset
strSql = "select valueA, valueB from table "
strWhere = ""
if conditionA then
strWhere = strWhere & "valueA like 'AB%' and "
if conditionB then
strWhere = strWhere & "valueB in ('X','Y','Z') and "
' many many if then else etc etc
if strWhere > "" then
strWhere = "where " & left(strWhere, len(strWhere)-5)
rs.open strSql & strWhere,adoConn,adOpenStatic, adLockReadOnly
Please No Spam, to email, change .com to .net