In the thread "How To Create a Candidate Key?" the following problem was discussed:
- Visual Basic application using ADO
- VFPOLEDB Connection
- Free Table (GHM_V70.DBF) with 87 Fields in Recordsets
- Recordset updates via rs1.Update failed because the
generated Update command is too long
- Can't use Primary Key on Free Tables
- Attempt to establish Candidate Key did not resolve
The problem was resolved by using a direct Update statement (versus rs1.Update) with the following code:
PA is an array that holds the field values. Because VFP has no knowledge of the array, an initial problem in specifying its use was resolved by using the [ ] characters in the above code for creating the UpdStr string.
I am now trying to add new records to the recordset. Hoping to do so easily I used the following code:
I get a Syntax Error on the conn1.Execute statement, presumably because VFP has no knowledge of the PA array. Is there (like there was for the Update statemnt) a way to use the array? Or, am I stuck with using the other syntax for INSERT INTO where I have to include all 87 Field names and their Values? Ala:
INSERT INTO dbf_name [(FieldName1 [,FieldName2, ...])]
VALUES (eExpression1 [, eExpression2, ...])
- Visual Basic application using ADO
- VFPOLEDB Connection
- Free Table (GHM_V70.DBF) with 87 Fields in Recordsets
- Recordset updates via rs1.Update failed because the
generated Update command is too long
- Can't use Primary Key on Free Tables
- Attempt to establish Candidate Key did not resolve
The problem was resolved by using a direct Update statement (versus rs1.Update) with the following code:
Code:
UpdStr = ""
For i = 0 To 86
UpdStr = UpdStr & Space(1) & rs1.Fields(i).NAME & "=[" & PA(i) & "]" & ","
Next i
UpdStr = Left(UpdStr, Len(UpdStr) - 1) & Space(1)
UpdStr = "UPDATE GHM_V70 SET " & UpdStr & "WHERE GS_ID = [" & PA(0) & "]"
conn1.Execute UpdStr
I am now trying to add new records to the recordset. Hoping to do so easily I used the following code:
Code:
AddStr = "INSERT INTO GHM_V70 FROM ARRAY PA
conn1.Execute AddStr
INSERT INTO dbf_name [(FieldName1 [,FieldName2, ...])]
VALUES (eExpression1 [, eExpression2, ...])