Really disconnect a recordset?
- From: "Mike Jansen" <mjansen_nntp@xxxxxxxx>
- Date: Tue, 23 Aug 2005 09:03:44 -0400
(Originally posted in microsoft.public.data.ado)
Is there a way to completely disconnect a recordset so that it has no memory
of its server origins? So that things like
rs.Field(0).Properties("BASETABLENAME") will be blank? So it doesn't know
it was created via OLE DB for SQL Server? So that it won't validate that
"hey you really can't update that on the server"?
I've got a recordset that comes from a query where some of the fields are
derived and not actual table fields. On the client side, I want to be able
to update those fields in the local recordset without ever doing an update
back to SQL Server. Because of the underlying schema and dynamic
properties, ADO is not allowing me to "update" the these fields.
Basically, I want to take the data from this recordset and put it into
another recordset with an identical "shallow" schema -- meaning same column
names and column types but none of the other attributes that link it to the
provider, so that I can manipulate it like a local-only recordset?
Do I basically need to create a new recordset by looping through the old
one's field defs and then copy the rows one by one?
Try this from VB6 with a reference to ADO 2.7:
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
con.CursorLocation = adUseClient
con.Open "Driver={SQL
Server};Server=(local);Database=master;Trusted_Connection=true"
rs.Open "SELECT 1 AS One", con, adOpenStatic, adLockOptimistic
Set rs.ActiveConnection = Nothing
con.Close
Set con = Nothing
rs("One") = 2 ' BOOOOM!!!!!!!!!
rs.Close
Set rs = Nothing
ADO is still validating the provider information even though it is
disconnected. If you check rs("One").Properties("BASETABLENAME") you'll see
that it's blank. On a column that really came from a table, this wouldn't be
blank and ADO would be OK with the update. All I'd like to do is strip away
all that provider information so it really behaves like a local-only record
set.
Thanks,
Mike
.
- Prev by Date: How to export data from Excel to Access2000 by using ADO ?
- Next by Date: Re: wanted: select query with has no result but with columns in re
- Previous by thread: How to export data from Excel to Access2000 by using ADO ?
- Next by thread: Empty recordset at asynchronous execution
- Index(es):
Relevant Pages
|