ADO Find Help?



Hi, I'm new to ADO and am hoping somebody here can steer me in the
right direction.

I'm using VB6, and an SQL database. I simply want to search the
database for a record containing two key values. For example, I want
to find a record where column A = xx, and column B = yy. I'm using
..Filter to do this, and believe I have it correct. Here's my filter
statement: .Filter = ("dbcolA = '" & valueA & "' and dbcolB = '" &
valueB & "'"). The result of this statement comes out to "dbcolA =
'valueA' and dbcolB = 'valueB'"

The next part I'm doing is either adding a new record to the table, or
updating the existing record, based on the result of the filter. The
way I'm doing this is as so:
If .EOF Then
.AddNew
End If
!dbcolA = valueA
!dbcolB = valueB
.Update
.Close
.Filter = adFilterNone

So, the only difference between a new record and an updated record is
the .AddNew statement.

The result of this is that when valueB changes, a new record is added
to the table as expected, but the valueB is propogated across all
records that contain valueA. I want it to create a new record, but not
touch any of the existing records.

What am I doing wrong??

Thanks very much...

.



Relevant Pages

  • Re: Sorting data to last 30 days
    ... I think you should explore applying the filter to the SQL database so that ... There are problems with trying to use AutoFilter here: custom criteria don't ... filter criteria. ...
    (microsoft.public.excel.misc)
  • Re: Database Filter question
    ... > I use ADO to connect to an SQL Database. ... I use an ADODataSet to hold a ... > When I set the Filtered property to True (ADODataset1.Filtered:= ... > will it automatically Execute its CommandText and then filter the new ...
    (borland.public.delphi.database.ado)
  • Re: ADO Find Help?
    ... Once the single record is found, ... > I'm using VB6, and an SQL database. ... > .Filter to do this, and believe I have it correct. ... > The result of this is that when valueB changes, ...
    (microsoft.public.data.ado)
  • Database Filter question
    ... I use ADO to connect to an SQL Database. ... I use an ADODataSet to hold a ... complete recordset from a select query. ... automatically Execute its CommandText and then filter the new resultset? ...
    (borland.public.delphi.database.ado)
  • Re: Database Filter question
    ... > Allan Nielsen wrote: ... >> I use ADO to connect to an SQL Database. ... I use an ADODataSet to hold a ... >> will it automatically Execute its CommandText and then filter the new ...
    (borland.public.delphi.database.ado)