|
-
Mar 21st, 2002, 12:07 PM
#1
Thread Starter
Frenzied Member
ADODB Recordset Update
Sorry to cross-post, but after getting no traffic in the other forum, I thought I might get better response here.
I have the following bit of code.
VB Code:
Dim myConn as New ADODB.Connection
Dim myRS as New ADODB.Recordset
myConn.Open "myDSN"
myRS.Open "SELECT * FROM myTable WHERE 0=1", myConn, adOpenDynamic, adLockBatchOptimistic
myRS.AddNew
myRS.Fields("Field1").Value = strFoo
myRS.Fields("Field2").Value = strBar
myRS.UpdateBatch
myRS.Close
myRS.Open "SELECT IndexField FROM myTable WHERE " & _
"Field1 = '" & strFoo & "' AND " & _
"Field2 = '" & strBar & "'", _
myConn, adOpenDynamic, adLockBatchOptimistic
intIndex = myRS.Fields("IndexField").Value
myRS.Close
Is there a safe way (that will work with MS Access, MS SQL Server, and Oracle) that I can get the autonumber field (IndexField) without closing and reopening the recordset? Are there any other places that I can make this code safer, use more accepted conventions?
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|