0   0

can u tell me code in vb6.0 for addnew item in table by adodc there is no primary key ,there is candidate key

Asked by: Anonymous User,

Answers

  0   0
Unverified new user

With table that has 3 columns.
1st column is "ID"
2nd is "FirstName"
3rd is "LastName"


Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

rs.Open "TableName", CurrentProject.Connection, adOpenKeyset, adLockOptimistic

rs.AddNew

rs(0)= 100 dont add this line if ID is auto number
rs(1)= "John"
rs(2)= "Doe"

rs.Update

rs.close


-Thats all there is to it.
-Make sure you reference ADO (Microsoft ActiveX Data Objects 6.0 Library)
-Your version may be 5.0 or something else.

Suggest a better answer

If you do not have an AfterDawn.com account yet, please enter your nickname and email address below. An activation link will be emailed to you.

If you already have an AfterDawn.com account, please login using the next tab.

Login by using your Afterdawn.com -username or your email address.


Ask.

150

Top users during the past 7 days

How the Top User chart works?

Subscribe to AfterDawn's weekly newsletter.