| | |
Error checking for an existing record
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Oct 2009
Posts: 25
Reputation:
Solved Threads: 0
i am trying to make sure that one record is not entered twice into the same database but the code i am using is giving me an error the error i am getting is but i am using adlockoptimistic as shown below which suports updating...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Set ri = deSub.conn.Execute("SELECT* FROM individualsubs WHERE firstname = '" & txtfname.Text & "' AND surname = '" & txtsurname.Text & "'") If ri.EOF = True Then ri.AddNew ri.Fields("firstname") = txtfname.Text ri.Fields("surname") = txtsurname.Text ri.Fields("numberofcopies") = x * Y ri.Fields("copiesout") = txtcopies.Text ri.Fields("copiesremaining") = x * Y ri.Update Else......
•
•
•
•
current recordset does not support updating. This might be a limitation of the provider or the selected locktype lock type
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
With ri .ActiveConnection = deSub.conn .LockType = adLockOptimistic .Source = "select * from individualsubs" .Open End With
•
•
Join Date: Oct 2009
Posts: 25
Reputation:
Solved Threads: 0
0
#2 Nov 8th, 2009
since i found roblems with adding a new record after checking if it was existant i then tried a another method but its giving me an error. the code is
one or more reqired fields is missing in the requested ordinal
what could be wrong with my code here
thatnx
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
deSub.conn.Execute ("INSERT INTO individualsubs VALUES (clientnumber = " & txtcopies.Text & ", surname = '" & txtsurname.Text & "', firstname = '" & txtfname.Text & "', nowdate = '" & DTPicker2.Value & "', numberofcopies = " & x * Y & ", copiesout = " & txtcopies.Text & ", copiesremaining = " & x * Y & ")")
one or more reqired fields is missing in the requested ordinal
what could be wrong with my code here
thatnx
•
•
Join Date: Mar 2009
Posts: 907
Reputation:
Solved Threads: 167
1
#3 Nov 8th, 2009
Okay, in your first post you set the lock type with the second code snippet but I don't see it in the first code snippet, which means if you have not explicitly set it, it defaults back to its default settings, which might be your problem.
Now, in your second post, you have formatted the insert statement incorrectly. Presently it looks more like an update statement but that is neither here nor there or the answer to your problem. So, a properly formatted insert statement looks like this...
Good Luck
Edit: to see correctly toggle to plain text
Now, in your second post, you have formatted the insert statement incorrectly. Presently it looks more like an update statement but that is neither here nor there or the answer to your problem. So, a properly formatted insert statement looks like this...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
strSQL = "INSERT INTO tablename(Numberfieldname1, Stringfieldname2) VALUES(" & VariableContainingNumberValueForFieldName1 & ",'" & VariableContainingStringValueForFieldName2 & "')"
Good Luck
Edit: to see correctly toggle to plain text
Last edited by vb5prgrmr; Nov 8th, 2009 at 10:11 am.
If anyone has helped you solve your problem, please mark your thread as solved.
Thanks
Thanks
![]() |
Similar Threads
- Custom error checking (C#)
- error checking (Java)
- User Form error checking (PHP)
- Help with 1.pointers and 2.error checking (C++)
- Error Checking for user input (Java)
- error checking of user input (C++)
- Basic Error Checking (C++)
- How to Perform Disk Error Checking in Windows XP (Windows tips 'n' tweaks)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: If then Statement in excel using data in 2-3 columns
- Next Thread: calling event form module
Views: 369 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





