Re: newbie: how to implement vb recordsets in stored procedures

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Louis Davidson (dr_dontspamme_sql_at_hotmail.com)
Date: 02/16/04


Date: Mon, 16 Feb 2004 11:29:44 -0600

Amen, brother! And don't feel bad about asking here for each and every case
where you cannot figure it out. There are a

Also, dont forget the key in the UPDATE:

UPDATE table1
SET field3 = 1
WHERE field1 > 0
     AND field2 > 0
     AND KeyField=<your value>

If it is something that you want to do often, do it in a procedure, you can
do something like:

create procedure table1_setField3
(
    @keyvalue datatype
) as
begin

    UPDATE table1
    SET field3 = 1
    WHERE field1 > 0
         AND field2 > 0
         AND KeyField=@keyValue

end

If you need to to > 1 modification statement, you need to use transactions
to protect your values. I would consider getting a book (or books online)
to read up on how the mechanics of tranactions, procedures, etc.

-- 
----------------------------------------------------------------------------
-----------
Louis Davidson (drsql@hotmail.com)
Compass Technology Management
Pro SQL Server 2000 Database Design
http://www.apress.com/book/bookDisplay.html?bID=266
Note: Please reply to the newsgroups only unless you are
interested in consulting services.  All other replies will be ignored :)
"William Morris" <news.remove.this.and.the.dots@seamlyne.com> wrote in
message news:c0qorj$18uu3l$1@ID-205671.news.uni-berlin.de...
> For the example you've posted, a simple update statement will give you
what
> you want.
>
> UPDATE table1
> SET field3 = 1
> WHERE field1 > 0
> AND field2 > 0
>
> If you're going to work in SQL you'll want to stop thinking in procedural
> terms.  Just about anything you'd want to do can be accomplished with SQL
> statements of varying complexity without resorting to vb-style coding.
Keep
> your eyes and your mind open; it's a big mental shift, but once you do
> you'll like the efficiency you get.
>
> -- 
> William Morris
> Product Development, Seritas LLC
> Kansas City, Missouri
>
> <Joost> wrote in message news:%23Upy9AK9DHA.1936@TK2MSFTNGP12.phx.gbl...
> > Hi group,
> >
> > Can sombody give me some pointers in how to convert visual basic code
with
> > recordsets to a stored procedures.
> >
> > For example: how should i implement the following.
> >
> >    Set rs = CurrentDb.OpenRecordset("SELECT * FROM Table1 WHERE
KeyField="
> &
> > mId)
> >    rs.Edit
> >
> >    If rs!Field1 > 0 And rs!Field2 > 0 Then
> >       rs!Field3 = 1
> >    End If
> >
> >    rs.Update
> >    rs.Close
> >
> > Please understand that this is only a short example. I have lots of
lines
> of
> > visual basic code thes way that specify the business rules.
> >
> > Any help is highly appreciated.
> >
> > Joost.
> >
> >
>
>