Re: NOT YOUR STANDARD QUESTION: SQL UPDATE in Disconnected Recordset

From: William \(Bill\) Vaughn (billvaRemoveThis_at_nwlink.com)
Date: 03/30/04


Date: Mon, 29 Mar 2004 17:31:46 -0800

Nope. The code engine that interprets the SQL is included in SQL Server,
JET, Oracle etc. ADO is simply an layer/interface to that engine.
There is nothing to stop you from writing your own SQL interpreter... but
I'm not sure how productive that would be.

-- 
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
"Alain Beaulieu" <abeaulieu@montreal.ds.adp.com> wrote in message
news:a79ff28e.0403291722.5ee1f3fa@posting.google.com...
> Hi all,
>
> I VERY often create a disconnected recordset in code from scratch,
> with no database connection, and with no intention to connect either
> (for sorting, for example). What I want to do here for the first time
> is issue an UPDATE "statement" on the recordset itself. Here is an
> example:
>
>     Dim oRecordset As Recordset
>     Set oRecordset = New Recordset
>
>     oRecordset.Fields.Append "Name", 200, 255
>     oRecordset.Fields.Append "Age", 200, 255
>     oRecordset.Open
>     oRecordset.AddNew
>     oRecordset("Name") = "Bob"
>     oRecordset("Age") = "34"
>     oRecordset.Update
>
>     oRecordset.AddNew
>     oRecordset("Name") = "Brian"
>     oRecordset("Age") = "35"
>     oRecordset.Update
>
>     oRecordset.AddNew
>     oRecordset("Name") = "Bill"
>     oRecordset("Age") = "41"
>     oRecordset.Update
>
>     oRecordset.Sort = "Age Desc"
>     oRecordset.MoveFirst
>
>     Do While Not oRecordset.EOF
>         'some code here...
>         oRecordset.MoveNext
>     Loop
>
> I would like to know if I can do an UPDATE on the recordset itself,
> somehow? For example:
>
> UPDATE *WHATEVER* SET AGE = 40 WHERE AGE > 40
>
> This would translate into something like:
>
> oRecorsdset.*SomeUpdatingMethod* = "Age = 40 WHERE Age > 40"
>
> Can I do this? If so, how? (I don't think so, but I want confirmation
> --> I've done a lot of research and I'm used to the Recordset object)
>
> I know I can do a loop and update the records individually, but the
> point here is that I want to use an UPDATE statement that the
> recordset would somehow interpret.
> Thanks.


Relevant Pages

  • Re: NOT YOUR STANDARD QUESTION: SQL UPDATE in Disconnected Recordset
    ... With an answer from Bill Vaughn himself, I don't think I need to look any more. ... The code engine that interprets the SQL is included in SQL Server, ...
    (microsoft.public.data.ado)
  • Re: Emailing a Report
    ... the reason Debug.Print was done was to test the SQL of what is being generated. ... If you will add and change data here, you need to set this up as a main/subform -- or just a main form that DISPLAYS data from Users and allows modifications to Agreements. ... If you are just going to send Agreements, then AgrID should be added to the form RecordSet so you can capture it. ... maybe also some kind of category for this followup type ...
    (microsoft.public.access.modulesdaovba)
  • Re: What is the advantage of Event programming?
    ... >> dice what lumps of data you need. ... which wouldn't work if the recordset has more than ... >My knowledge on using SQL statements is somewhat limited. ... Requesting a limited number of records at a time, was useful in the old days ...
    (microsoft.public.vb.general.discussion)
  • Re: REPOST: One Web Service updates SQL, the other cant
    ... insert is executed a reference to rs.eof is invalid and the program bombs. ... > get recordset back and ADO could generate error here. ... Another instance of the same Web Service code, ... >> Watching both the debugger and the trace, SQL is receiving what I send ...
    (microsoft.public.vb.database.ado)
  • Re: using Command to set Parameters and Recordset to retrive the Query
    ... doesn't the rsData will be interpretate as an input parameter in the SP? ... >> Query and retrive the Recordset so I can use the Paging property ... > Even if this technique of using the parameters in the ORDER BY does work for> you, I suspect that this will defeat your objective of preventing sql> injection. ... See below for a more efficient solution> using a stored procedure. ...
    (microsoft.public.inetserver.asp.general)