473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

simple command button question

Hi,
I am trying to create a simple asp page that has one command button that
updates a database. The URL of the page is like this:

http://MyServer.com/Update.asp?UserName=Tom

My asp code is like this:

%@ Language=VBScript %>
<!--#include file="includes/openconnection.asp"-->

StringUserName = Request.QueryString("UserName")

StringSQL = UPDATE Users SET Current = 0 WHERE UserName = '" &
StringUserName & "'")

I need to build the command button so that it shows up on my page and then
execute StringSQL when the user clicks the button. How do I do this?

Thanks,
Sam

Jul 19 '05 #1
13 4726
Tim
look at html FORMs
post to another asp page to do the work.

when you can get the form in html working and posting, only then write the
asp page to capture what was posted (response.form or response.querystring)
and then with asp hit the database

sorry to be a bit vague - but it's a but of a vague question
Tim
"Samantha Smit" <sa******@spamaway.cybermesa.com> wrote in message
news:bl**********@reader2.nmix.net...
Hi,
I am trying to create a simple asp page that has one command button that
updates a database. The URL of the page is like this:

http://MyServer.com/Update.asp?UserName=Tom

My asp code is like this:

%@ Language=VBScript %>
<!--#include file="includes/openconnection.asp"-->

StringUserName = Request.QueryString("UserName")

StringSQL = UPDATE Users SET Current = 0 WHERE UserName = '" &
StringUserName & "'")

I need to build the command button so that it shows up on my page and then
execute StringSQL when the user clicks the button. How do I do this?

Thanks,
Sam

Jul 19 '05 #2
You realize of course that you will be setting all of your "Current" fields
to 0 if the UserName is Tom, right?

Page1.asp
<form method=get action=Page2.asp>
<input type=submit name="UserName" value="Tom">
</form>
<a href="Page2.asp?UserName=Tom">Click Here</a>

Page2.asp is the code you submitted, plus the line

connectionObject.Execute stringSQL

"Samantha Smit" <sa******@spamaway.cybermesa.com> wrote in message
news:bl**********@reader2.nmix.net...
Hi,
I am trying to create a simple asp page that has one command button that
updates a database. The URL of the page is like this:

http://MyServer.com/Update.asp?UserName=Tom

My asp code is like this:

%@ Language=VBScript %>
<!--#include file="includes/openconnection.asp"-->

StringUserName = Request.QueryString("UserName")

StringSQL = UPDATE Users SET Current = 0 WHERE UserName = '" &
StringUserName & "'")

I need to build the command button so that it shows up on my page and then
execute StringSQL when the user clicks the button. How do I do this?

Thanks,
Sam

Jul 19 '05 #3

"Tom B" <sh*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
You realize of course that you will be setting all of your "Current" fields to 0 if the UserName is Tom, right?


Wouldn't that be the goal?

Ray at work
Jul 19 '05 #4
CJ

"Tom B" <sh*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
You realize of course that you will be setting all of your "Current" fields to 0 if the UserName is Tom, right?
Yes, my real data is unique, I just thought I'd simplify the example.

I'm confused why I need 2 pages, sorry I'm new at this. Maybe additional
details would help. I want to include a URL in an email message that would
allow the recipient to change their "Current" field so they don't receive
emails in the future, sort of an unsubscribe process. The URL link in the
email will be like http://MyServer.com/Update.asp?UserName=Tom The user will
click on the link, load the asp page, and then click on the command button
which would update their record. I'm trying the method with two pages but
can't get anything to work. I'll keep trying. Any help is appreciated.

thanks,
Sam Page1.asp
<form method=get action=Page2.asp>
<input type=submit name="UserName" value="Tom">
</form>
<a href="Page2.asp?UserName=Tom">Click Here</a>

Page2.asp is the code you submitted, plus the line

connectionObject.Execute stringSQL

"Samantha Smit" <sa******@spamaway.cybermesa.com> wrote in message
news:bl**********@reader2.nmix.net...
Hi,
I am trying to create a simple asp page that has one command button that
updates a database. The URL of the page is like this:

http://MyServer.com/Update.asp?UserName=Tom

My asp code is like this:

%@ Language=VBScript %>
<!--#include file="includes/openconnection.asp"-->

StringUserName = Request.QueryString("UserName")

StringSQL = UPDATE Users SET Current = 0 WHERE UserName = '" &
StringUserName & "'")

I need to build the command button so that it shows up on my page and then execute StringSQL when the user clicks the button. How do I do this?

Thanks,
Sam


Jul 19 '05 #5
I assume so, but I thought I'd mention it.
Personally, I wouldn't use a string value as a Unique ID.
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:Oo*************@tk2msftngp13.phx.gbl...

"Tom B" <sh*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
You realize of course that you will be setting all of your "Current"

fields
to 0 if the UserName is Tom, right?


Wouldn't that be the goal?

Ray at work

Jul 19 '05 #6
Hi Chris/CJ/Sam,

You don't need to do it in two pages. It makes things easier for learning
though. I personally often use three pages for such things, actually. My
three pages would be like this:

page1.asp:

<form method="POST" action="page2.asp"> <!--note the method is post, not
get-->
Current username: <input type="text" name="txtCurrentUsername" /><br />
New username: <input type="text" name="txtNewUsername" /><br />
<input type="submit" />
</form>

page2.asp:

<%
Dim sCurrentUsername, sNewUsername
Dim sSQL, oADO

sCurrentUsername = Request.Form("txtCurrentUsername")
sNewUsername = Request.Form("txtNewUsername")
sSQL = "UPDATE TheTable SET TheUsername='" & sNewUsername & "' WHERE
TheUsername='" & sCurrentUsername & "'"
Set oADO = Server.CreateObject("ADODB.Connection")
oADO.Open MyConnectionString
oADO.Execute sSQL
oADO.Close : Set oADO = Nothing
Response.Redirect "page3.asp"
%>

page3.asp:

<body>Thank you</body>

Does that make sense? It's just a basic example of things.

Ray at work
"CJ" <ch***@hrn.org> wrote in message news:bl**********@reader2.nmix.net...

Yes, my real data is unique, I just thought I'd simplify the example.

I'm confused why I need 2 pages, sorry I'm new at this. Maybe additional
details would help. I want to include a URL in an email message that would
allow the recipient to change their "Current" field so they don't receive
emails in the future, sort of an unsubscribe process. The URL link in the
email will be like http://MyServer.com/Update.asp?UserName=Tom The user will click on the link, load the asp page, and then click on the command button which would update their record. I'm trying the method with two pages but
can't get anything to work. I'll keep trying. Any help is appreciated.

thanks,
Sam

Jul 19 '05 #7
You, I, and a handful of other people are the only ones in the world who
think that way then. I get so homicidal when I think about all the software
that I have to deal with where I work that uses usernames as the unique ID.
This is how things flow where I work:

1. Ray, we bought this software. It uses SQL Server. Support it.
2. Okay, I have the server setup and the database created to their specs.
Give me a contact name of someone there. I have a question.
3. Person at software company, I have a question. It appears that you use a
person's username as the unique ID. Why? What happens when one of our
users gets married and she wants to change her username to conform to her
new name.
4. You can't change the username. It's tied to too many other things.
5. I want to kill people at your company. Bye.

Yeah, sure, if I wanted to, I could change the username and update all the
references to it elsewhere, but if I start modifying the database directly
myself, I violate support contracts.

That would be enough of my whining for now though. :]

Ray at work

"Tom B" <sh*****@hotmail.com> wrote in message
news:OD****************@TK2MSFTNGP10.phx.gbl...
I assume so, but I thought I'd mention it.
Personally, I wouldn't use a string value as a Unique ID.
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:Oo*************@tk2msftngp13.phx.gbl...

"Tom B" <sh*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
You realize of course that you will be setting all of your "Current"

fields
to 0 if the UserName is Tom, right?


Wouldn't that be the goal?

Ray at work


Jul 19 '05 #8
You don't need two pages.
Your link idea would work fine.

Update.asp
<%
Dim sUser
sUser=Request.QueryString("UserName")
if Request.QueryString("Postback")="true" then
'Open connection to database
Dim sSQL
sSQL="UPDATE Users Set Current=0 WHERE UserName='" & sUser& "'"
connectionObject.Execute sSQL
Response.Write "Database Updated"
end if
%>

<input type=hidden name=Postback Value="true">
<Form method=Get action=Update.asp>

<input type=hidden name=UserName Value="<%=sUser%>">
<input type=Submit name="Go">
</Form>

"CJ" <ch***@hrn.org> wrote in message news:bl**********@reader2.nmix.net...

"Tom B" <sh*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
You realize of course that you will be setting all of your "Current" fields
to 0 if the UserName is Tom, right?


Yes, my real data is unique, I just thought I'd simplify the example.

I'm confused why I need 2 pages, sorry I'm new at this. Maybe additional
details would help. I want to include a URL in an email message that would
allow the recipient to change their "Current" field so they don't receive
emails in the future, sort of an unsubscribe process. The URL link in the
email will be like http://MyServer.com/Update.asp?UserName=Tom The user

will click on the link, load the asp page, and then click on the command button which would update their record. I'm trying the method with two pages but
can't get anything to work. I'll keep trying. Any help is appreciated.

thanks,
Sam
Page1.asp
<form method=get action=Page2.asp>
<input type=submit name="UserName" value="Tom">
</form>
<a href="Page2.asp?UserName=Tom">Click Here</a>

Page2.asp is the code you submitted, plus the line

connectionObject.Execute stringSQL

"Samantha Smit" <sa******@spamaway.cybermesa.com> wrote in message
news:bl**********@reader2.nmix.net...
Hi,
I am trying to create a simple asp page that has one command button that updates a database. The URL of the page is like this:

http://MyServer.com/Update.asp?UserName=Tom

My asp code is like this:

%@ Language=VBScript %>
<!--#include file="includes/openconnection.asp"-->

StringUserName = Request.QueryString("UserName")

StringSQL = UPDATE Users SET Current = 0 WHERE UserName = '" &
StringUserName & "'")

I need to build the command button so that it shows up on my page and then execute StringSQL when the user clicks the button. How do I do this?

Thanks,
Sam



Jul 19 '05 #9
I'll admit I got burned the first time I wrote something that was used in
production. I didn't use the names as a UniqueID, but I didn't record the
"current name" as part of a transaction either. So when a person got
married, or changed their name for other reasons, I was able to change the
name, but it was reflected on the old data as well. Which of course, wasn't
right either.

My main motivation for using int's for UniqueIDs is purely because of my
belief that computers can handle them faster. I believe one of the normal
forms also suggests that the UniqueID should be irrelevant to the data (I
don't think that's the right way to put it) meaning that if it's related to
the data, it shouldn't be used. Thus, a name, SIN(SSI) etc. are not good
candidates.

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:Ow**************@TK2MSFTNGP11.phx.gbl...
You, I, and a handful of other people are the only ones in the world who
think that way then. I get so homicidal when I think about all the software that I have to deal with where I work that uses usernames as the unique ID. This is how things flow where I work:

1. Ray, we bought this software. It uses SQL Server. Support it.
2. Okay, I have the server setup and the database created to their specs.
Give me a contact name of someone there. I have a question.
3. Person at software company, I have a question. It appears that you use a person's username as the unique ID. Why? What happens when one of our
users gets married and she wants to change her username to conform to her
new name.
4. You can't change the username. It's tied to too many other things.
5. I want to kill people at your company. Bye.

Yeah, sure, if I wanted to, I could change the username and update all the
references to it elsewhere, but if I start modifying the database directly
myself, I violate support contracts.

That would be enough of my whining for now though. :]

Ray at work

"Tom B" <sh*****@hotmail.com> wrote in message
news:OD****************@TK2MSFTNGP10.phx.gbl...
I assume so, but I thought I'd mention it.
Personally, I wouldn't use a string value as a Unique ID.
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:Oo*************@tk2msftngp13.phx.gbl...

"Tom B" <sh*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> You realize of course that you will be setting all of your "Current"
fields
> to 0 if the UserName is Tom, right?

Wouldn't that be the goal?

Ray at work



Jul 19 '05 #10
Thanks for responding Tom. My page currently looks like this:
<%
Dim sUser
sUser=Request.QueryString("UserName")
if Request.QueryString("Postback")="true" then
'Open connection to database
<!--#include file="includes/openconnection.asp"-->
Dim sSQL
sSQL="UPDATE Users Set Status=1 WHERE UserName='" & sUser& "'"
connectionObject.Execute sSQL
Response.Write "Database Updated"
end if
%>
<input type=hidden name=Postback Value="true">
<Form method=Get action=Update.asp>

<input type=hidden name=UserName Value="<%=sUser%>">
<input type=Submit name="Go">
</Form>

I load the URL http://MyServer.com/Update.asp?UserName=Tom. I see the button
called "Submit query". When I click it the URL changes to
http://MyServer.com/Update.asp?UserN...o=Submit+Query

I don't see the Database Updated message and my data is not updated. My
openconnection.asp file is working for a different page. The following
update SQL statement works in Query Analyzer, UPDATE Users Set Status =1
WHERE UserName = "Tom"

If I comment out "if Request.QueryString("Postback")="true" then.....End IF
I get
Microsoft VBScript runtime (0x800A01A8)
Object required: 'connectionObject'
/Test/Update.asp, line 13

Also where can I edit the label on the command button, I don't see the text
"Submit Query" anywhere. Is this some kind of default label.

Thanks for any help that you may be willing to provide.

Sam
"Tom B" <sh*****@hotmail.com> wrote in message
news:u1**************@TK2MSFTNGP12.phx.gbl...
You don't need two pages.
Your link idea would work fine.

Update.asp
<%
Dim sUser
sUser=Request.QueryString("UserName")
if Request.QueryString("Postback")="true" then
'Open connection to database
Dim sSQL
sSQL="UPDATE Users Set Current=0 WHERE UserName='" & sUser& "'"
connectionObject.Execute sSQL
Response.Write "Database Updated"
end if
%>

<input type=hidden name=Postback Value="true">
<Form method=Get action=Update.asp>

<input type=hidden name=UserName Value="<%=sUser%>">
<input type=Submit name="Go">
</Form>

"CJ" <ch***@hrn.org> wrote in message

news:bl**********@reader2.nmix.net...

"Tom B" <sh*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
You realize of course that you will be setting all of your "Current"

fields
to 0 if the UserName is Tom, right?


Yes, my real data is unique, I just thought I'd simplify the example.

I'm confused why I need 2 pages, sorry I'm new at this. Maybe additional
details would help. I want to include a URL in an email message that would
allow the recipient to change their "Current" field so they don't receive emails in the future, sort of an unsubscribe process. The URL link in the email will be like http://MyServer.com/Update.asp?UserName=Tom The user

will
click on the link, load the asp page, and then click on the command

button
which would update their record. I'm trying the method with two pages but can't get anything to work. I'll keep trying. Any help is appreciated.

thanks,
Sam
Page1.asp
<form method=get action=Page2.asp>
<input type=submit name="UserName" value="Tom">
</form>
<a href="Page2.asp?UserName=Tom">Click Here</a>

Page2.asp is the code you submitted, plus the line

connectionObject.Execute stringSQL

"Samantha Smit" <sa******@spamaway.cybermesa.com> wrote in message
news:bl**********@reader2.nmix.net...
> Hi,
> I am trying to create a simple asp page that has one command button that > updates a database. The URL of the page is like this:
>
> http://MyServer.com/Update.asp?UserName=Tom
>
> My asp code is like this:
>
> %@ Language=VBScript %>
> <!--#include file="includes/openconnection.asp"-->
>
> StringUserName = Request.QueryString("UserName")
>
> StringSQL = UPDATE Users SET Current = 0 WHERE UserName = '" &
> StringUserName & "'")
>
> I need to build the command button so that it shows up on my page

and then
> execute StringSQL when the user clicks the button. How do I do this?
>
> Thanks,
> Sam
>
>
>



Jul 19 '05 #11
I love it!

Mine is a little different.

1. Phil calls software company.
2. Software company says, reboot the server to fix it
3. Phil reboots server, asks what is wrong with software
3. Software won't admit that they really don't know. Then they ask
why I don't reboot the server once a week to keep the software running
4. Phil asks why they don't fix the software so I don't heave to
reboot once a week.
5. Phil is considered to be a "pain" :-)
--

Phillip Windell [CCNA, MVP, MCP]
pw******@wandtv.com
WAND-TV (ABC Affiliate)
www.wandtv.com

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in
message news:Ow**************@TK2MSFTNGP11.phx.gbl...
You, I, and a handful of other people are the only ones in the world who think that way then. I get so homicidal when I think about all the software that I have to deal with where I work that uses usernames as the unique ID. This is how things flow where I work:

1. Ray, we bought this software. It uses SQL Server. Support it.
2. Okay, I have the server setup and the database created to their specs. Give me a contact name of someone there. I have a question.
3. Person at software company, I have a question. It appears that you use a person's username as the unique ID. Why? What happens when one of our users gets married and she wants to change her username to conform to her new name.
4. You can't change the username. It's tied to too many other things. 5. I want to kill people at your company. Bye.

Jul 19 '05 #12
Nice!

See, this one of the reasons that no matter what the non-believers say about
Microsoft, they make good software. If they made software that required
such a routine, they'd fix it. And they know how to make their software
work together and not cause conflicts. If you setup an NT* machine and put
nothing but Microsoft software on it, it'll run forever flawlessly. Then
you go and install some junkware that you download off the Internet and
start getting Dr. Watsons all the time, and suddenly it's Microsoft's fault.
I can't stand that.

The above statements are meant to be generally true. I am aware that
nothing is 100%. :]

Ray at work

"Phillip Windell" <pwindell{at}wandtv*d0t*com> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...
I love it!

Mine is a little different.

1. Phil calls software company.
2. Software company says, reboot the server to fix it
3. Phil reboots server, asks what is wrong with software
3. Software won't admit that they really don't know. Then they ask
why I don't reboot the server once a week to keep the software running
4. Phil asks why they don't fix the software so I don't heave to
reboot once a week.
5. Phil is considered to be a "pain" :-)

Jul 19 '05 #13
"Tom B" <sh*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I'll admit I got burned the first time I wrote something that was used in production. I didn't use the names as a UniqueID, but I didn't record the "current name" as part of a transaction either. So when a person got
married, or changed their name for other reasons, I was able to change the name, but it was reflected on the old data as well. Which of course, wasn't right either.

My main motivation for using int's for UniqueIDs is purely because of my belief that computers can handle them faster. I believe one of the normal forms also suggests that the UniqueID should be irrelevant to the data (I don't think that's the right way to put it) meaning that if it's related to the data, it shouldn't be used. Thus, a name, SIN(SSI) etc. are not good candidates.


I think the term is "non-meaningful" keys. I wish they would come up
with a term that doesn't carry such a negative connotation. How about
"keys that won't screw you down the line". Yes, that sums it up nicely.
:)

-Chris Hohmann
Jul 19 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: max(01)* | last post by:
hello. i wrote a very simple tkinter demo program that uses menus, buttons, labels, entries, frames and secondary toplevels. it is a python version of a java program made by a colleague. ...
3
by: Nhmiller | last post by:
I searched here for an answer. I am entering records into a database, and it would save a lot of time if I could duplicate a record that is very similar to the new one I am about to enter, then...
6
by: Rodger Arndt | last post by:
I have a program that is in need of keeping track of how many times the command button has been clicked . I have a dollar amount totaled in a label, every time the user clicks the command button...
2
by: James | last post by:
I have a very simple datagrid, with an edit button that I added in PropertyBuilder. This fires the EditCommand event just fine and I show a panel where the user can edit certain fields. I have a...
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
2
by: Kevin S. Goff | last post by:
Hi....I realize this is a really basic question.... I have a webform (in VS.NET 2005). It has (among other things) a combobox and a command button. At the beginning, the command button is...
1
by: Eric_Dexter | last post by:
I am just trying to acess a function in wordgrid (savefile) to a button that is defined in TestFrame. I can't seem to make it work I either get an error that my variable isn't global or it makes...
5
by: eric dexter | last post by:
I am just trying to acess a function in wordgrid (savefile) to a button that is defined in TestFrame. I can't seem to make it work I either get an error that my variable isn't global or it makes...
4
by: gmarkowsky | last post by:
Hi all, I'm trying to write a GUI that will put up multiple widgets in succession. My problem is that each widget also contains the previous widgets when they pop up. How do I reinitialize the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.