473,854 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=VBScri pt %>
<!--#include file="includes/openconnection. asp"-->

StringUserName = Request.QuerySt ring("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 4760
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.querys tring)
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******@spama way.cybermesa.c om> 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=VBScri pt %>
<!--#include file="includes/openconnection. asp"-->

StringUserName = Request.QuerySt ring("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.as p>
<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

connectionObjec t.Execute stringSQL

"Samantha Smit" <sa******@spama way.cybermesa.c om> 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=VBScri pt %>
<!--#include file="includes/openconnection. asp"-->

StringUserName = Request.QuerySt ring("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*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.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*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.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.as p>
<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

connectionObjec t.Execute stringSQL

"Samantha Smit" <sa******@spama way.cybermesa.c om> 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=VBScri pt %>
<!--#include file="includes/openconnection. asp"-->

StringUserName = Request.QuerySt ring("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******** *****@tk2msftng p13.phx.gbl...

"Tom B" <sh*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.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.a sp"> <!--note the method is post, not
get-->
Current username: <input type="text" name="txtCurren tUsername" /><br />
New username: <input type="text" name="txtNewUse rname" /><br />
<input type="submit" />
</form>

page2.asp:

<%
Dim sCurrentUsernam e, sNewUsername
Dim sSQL, oADO

sCurrentUsernam e = Request.Form("t xtCurrentUserna me")
sNewUsername = Request.Form("t xtNewUsername")
sSQL = "UPDATE TheTable SET TheUsername='" & sNewUsername & "' WHERE
TheUsername='" & sCurrentUsernam e & "'"
Set oADO = Server.CreateOb ject("ADODB.Con nection")
oADO.Open MyConnectionStr ing
oADO.Execute sSQL
oADO.Close : Set oADO = Nothing
Response.Redire ct "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.or g> 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*****@hotmai l.com> wrote in message
news:OD******** ********@TK2MSF TNGP10.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******** *****@tk2msftng p13.phx.gbl...

"Tom B" <sh*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.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.Q ueryString("Use rName")
if Request.QuerySt ring("Postback" )="true" then
'Open connection to database
Dim sSQL
sSQL="UPDATE Users Set Current=0 WHERE UserName='" & sUser& "'"
connectionObjec t.Execute sSQL
Response.Write "Database Updated"
end if
%>

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

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

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

"Tom B" <sh*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.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.as p>
<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

connectionObjec t.Execute stringSQL

"Samantha Smit" <sa******@spama way.cybermesa.c om> 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=VBScri pt %>
<!--#include file="includes/openconnection. asp"-->

StringUserName = Request.QuerySt ring("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******** ******@TK2MSFTN GP11.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*****@hotmai l.com> wrote in message
news:OD******** ********@TK2MSF TNGP10.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******** *****@tk2msftng p13.phx.gbl...

"Tom B" <sh*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.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

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

Similar topics

5
3015
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. the user can create ("Scrivi") a record with his second name, first name and date of birth, save ("Salva") the record to a file or read in ("Leggi") a previously created file. "Annulla" is to cancel. "Chiudi" is
3
28849
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 make one or two changes to the new one. This is the problem I have with Access. Look at this answer! >Private Sub btnCopy_Click() >On Error GoTo handle_error > Set cnxn = CurrentProject.Connection > Set rs = New ADODB.Recordset
6
1680
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 represents 1 customers order. I want to find the average per customer for daily sales. Is there a simple way to just keep track of the number of times a command button has been clicked?
2
1225
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 button to save the changes. Within that button, I refer to dataGrid1.EditItemIndex and it's returning -1. Isn't this property set when I click on the edit button within the grid?
14
4984
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 for things like delete, save, edit, cancel buttons - in the footer, or on the form detail section? 2. If in the footer, how do you add them to the tab order?
2
1074
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 disabled....on the selectedindexchanged event of the combobox, I want to enable the command button Only way I know to do it is in the code-behind .CS file with a postback, but I'd rather do it with Javascript....except I really don't know the...
1
1254
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 other complaints. thanks in advance.. sorry for the simple question.. import wx import wx.grid as gridlib
5
1474
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 other complaints. thanks in advance.. sorry for the simple question.. import wx import wx.grid as gridlib import sys
4
1579
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 widget each time so that it doesn't contain earlier ones? Actually, another question I have is, is there a way to set python so that it will assume any undefined variable is 0 or ''? That is, I have several statements like "If k 0 then so and so"...
0
9901
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9750
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11024
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10672
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9510
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7909
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7077
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4150
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.