Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 Disconnected Recordset question 1

Status
Not open for further replies.

jtseltmann

Programmer
Jan 15, 2002
149
US
I have created a simple disconnected recordset in one of my apps that just tracks record processed and some other data on the fly. I'm wondering if there is a way to assign a primary key value to the first field I appended in the recordset. I have searched and searched and cannot find any help.

My code is simply just:

Dim rs as ADODB.Recordset
Set rs = NEW ADODB.Recordset
With rs.Fields
.append "field1", adVarChar, 50
.append "field2", adVarChar, 50
End with
rs.CursorType = adUseClient
rs.LockType = adLockBatchOptimistic
rs.Open

then i add records on the fly. I want to have field1 be a key value to I know if dupes are added. Rather then checking each time I thought I could assign it a primary key. I can find nothing on this...

Anyone have any thougths for me?
Thanks.
 
What code are you using now to determine if duplicates exist?

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Investigate [tt]adFldKeyColumn[/tt], which will briefly look promising. Then you will find it doesn't appear to work, allowing duplicates to be added. And the reason is that sadly it is only enforced, as far as I recall, when you connect the recordset to a backend database ...
 
Thanks everyone for the helpful hints. I finally just realized that using the following:

rs.movefirst
rs.Find("field1 = 'xx')

will work perfectly. I must have missed that when going through all the other iterations.
Thanks everyone
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top