|
-
Sep 17th, 2003, 08:28 AM
#1
Thread Starter
Hyperactive Member
Selection String still applied to Recordset
2 programers have 2 different ways of opening recordsets.
1st way - retrieve 1 record to Update
VB Code:
With DataEnvironment1.rstblLabs
If .State = adStateOpen Then .Close
.Open "SELECT * FROM tblLabs WHERE pkLab = " & p_pkLab, _
, adOpenStatic, adLockOptimistic
2nd way - retrieve all records to fill a combobox
after the 1st way has already happened
VB Code:
With RS
If Not .State = adStateOpen Then
.Open , , adOpenStatic, adLockOptimistic
When the second query to this table is executed the only
record retrieved is the one from the 1st query. Is there any
way to clear out the selection string from the 1st query and
just retrieve all the records without passing a new selection
string? This code is everywhere in the program so a major
code change would be good to avoid.
-
Sep 17th, 2003, 09:34 AM
#2
Thread Starter
Hyperactive Member
Maybe a better Question.....
Is there a way (a property on the command object or the
DataEnvironment) to force VB to query the Database and
return all records on the .Open command if no selection
string is specified????
-
Sep 18th, 2003, 07:57 AM
#3
Thread Starter
Hyperactive Member
Is this a solid solution???
Please view the comments in the code below:
VB Code:
'I send a Selection String with this statement
With DataEnvironment1.rstblHealthProfile
.Open "SELECT * FROM tblHealthProfile WHERE 1 <> 1", , adOpenStatic, adLockOptimistic
' The .Source property of the recordset now holds that selection
' string until another is issued. So the .Open method will send the
' same query next time it is executed. The statement below
' initialized the recordset (along with all other recordsets).
Set DataEnvironment1 = Nothing
' Next time the recordset is opened the .Source is reset to
' select * from "dbo"."tblHealthProfile"
Is this a solid solution?? Is this proper procedure and good coding
to intialize the Dataenvironment like this??
My co-workers say that it is the same as deallocating memory but
I am under the impression that this is the same as setting an
Integer value equal to 0. The solution works but are there any
downfalls???
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
|