need urgent help please

need urgent help please

am 12.08.2006 16:39:53 von kester21

hi, i am trying to update a recordset in access using a variable
for example

varStore = "4th Avenue Store" or it could be "10st Street Store"

my recordset is rstStore

i want to post to my recordset like this

rstStore!" & varStore & " = 5000

but it doesn't work, ANY IDEAS PLEASE

Re: need urgent help please

am 12.08.2006 21:17:16 von Mike Brind

kester21 wrote:
> hi, i am trying to update a recordset in access using a variable
> for example
>
> varStore = "4th Avenue Store" or it could be "10st Street Store"
>
> my recordset is rstStore
>
> i want to post to my recordset like this
>
> rstStore!" & varStore & " = 5000
>
> but it doesn't work, ANY IDEAS PLEASE

What's the relevance of the 5000? Can you provide more of the code
before and after the line you have shown? Particularly any lines that
throw errors, and details of the errors. What is your table called?
What are the field names and types?

--
Mike Brind

Re: need urgent help please

am 14.08.2006 13:02:19 von jeff.nospam

On 12 Aug 2006 07:39:53 -0700, "kester21"
wrote:

>hi, i am trying to update a recordset in access using a variable
>for example
>
>varStore = "4th Avenue Store" or it could be "10st Street Store"
>
>my recordset is rstStore
>
>i want to post to my recordset like this
>
>rstStore!" & varStore & " = 5000
>
>but it doesn't work, ANY IDEAS PLEASE

How about telling us what "doesn't work" means to you and give us an
example of what would be "does work"?

From your code I have no idea what you expect to do.

Jeff

Re: need urgent help please

am 14.08.2006 13:12:37 von reb01501

kester21 wrote:
> hi, i am trying to update a recordset in access using a variable
> for example
>
> varStore = "4th Avenue Store" or it could be "10st Street Store"
>
> my recordset is rstStore
>
> i want to post to my recordset like this
>
> rstStore!" & varStore & " = 5000
>

1. This is not the correct syntax. You would need to use:
rsStore(varStore) = 5000

2. It is not advisable to use a recordset to maintain data in ASP
applications. In ASP, recordsets should be used solely to retrieve read-only
data for display purposes. Use SQL DML statements (INSERT, UPDATE and
DELETE) to maintain data. In fact, my preferred practice is to use saved
parameter queries. See:
http://www.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&sel m=e6lLVvOcDHA.1204%40TK2MSFTNGP12.phx.gbl

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1& selm=eHYxOyvaDHA.4020%40tk2msftngp13.phx.gbl

In this case howeverm it appears that you don't know which fields you will
be updating so you will need to build the statement at runtime:

sql="UPDATE table SET " & varStore & _
"5000 WHERE ... "

See here for the best way to execute statements that are built in code:
http://groups-beta.google.com/group/microsoft.public.inetser ver.asp.db/msg/72e36562fee7804e



--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Re: need urgent help please

am 14.08.2006 13:13:34 von Daniel Crichton

kester21 wrote on 12 Aug 2006 07:39:53 -0700:

> hi, i am trying to update a recordset in access using a variable
> for example
>
> varStore = "4th Avenue Store" or it could be "10st Street Store"
>
> my recordset is rstStore
>
> i want to post to my recordset like this
>
> rstStore!" & varStore & " = 5000
>
> but it doesn't work, ANY IDEAS PLEASE


If you're trying to update a column with the name of varStore then this will work:

rstStore.Fields(varStore).Value = 5000

This can be shortened as the Fields collection is the default for a
recordset object, and the Value property is the default for a Field object, to:

rstStore(varStore) = 5000

Is that what you're trying to do?

I keep seeing the use of ! in code in many of these newsgroups, why are
people still using it? The "bang operator" was part of DAO, that's pretty
much dead and buried. If you're using ADO, please learn to use it correctly.

Dan

Re: need urgent help please

am 14.08.2006 14:55:58 von reb01501

Daniel Crichton wrote:
> ... If you're using ADO, please learn to use it correctly.


I don't think you intended it as such but this seems a little harsh. The
obvious retort from the OP would be "I believe that's what I'm trying to
do: learn how to use it correctly."

Perhaps a pointer to the documentation at MSDN would be wothwhile for
the OP:
http://msdn.microsoft.com/library/en-us/ado270/htm/dasdkadoo verview.asp
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Re: need urgent help please

am 14.08.2006 15:08:17 von Daniel Crichton

Bob wrote on Mon, 14 Aug 2006 08:55:58 -0400:

> Daniel Crichton wrote:
>> ... If you're using ADO, please learn to use it correctly.
>
> I don't think you intended it as such but this seems a little harsh. The
> obvious retort from the OP would be "I believe that's what I'm trying to
> do: learn how to use it correctly."
>
> Perhaps a pointer to the documentation at MSDN would be wothwhile for
> the OP:
> http://msdn.microsoft.com/library/en-us/ado270/htm/dasdkadoo verview.asp



Maybe I did come over a big strong. It just amazes me that so many people
are not following the documentation. I guess most of them copy code from a
web site article and go from there, and as people post more and more code
based on the same flawed original code it spirals out of control.

Dan

Re: need urgent help please

am 14.08.2006 15:31:29 von reb01501

Daniel Crichton wrote:
> Bob wrote on Mon, 14 Aug 2006 08:55:58 -0400:
>
>> Daniel Crichton wrote:
>>> ... If you're using ADO, please learn to use it correctly.
>>
>> I don't think you intended it as such but this seems a little harsh.
>> The obvious retort from the OP would be "I believe that's what I'm
>> trying to do: learn how to use it correctly."
>>
>> Perhaps a pointer to the documentation at MSDN would be wothwhile for
>> the OP:
>>
http://msdn.microsoft.com/library/en-us/ado270/htm/dasdkadoo verview.asp
>
>
>
> Maybe I did come over a big strong. It just amazes me that so many
> people are not following the documentation. I guess most of them copy
> code from a web site article and go from there, and as people post
> more and more code based on the same flawed original code it spirals
> out of control.
>
No argument there. I get frustrated by this myself, especially since
many of the flawed examples come from msdn.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.