Ask a Question related to ASP Database, Design and Development.
-
Vivista Eastbourne #1
Problem with data in 2 forms: Please help
Hi Nicole,
Thanks again.
The Database is an Access database called userdetails.mdb
The table is called UserDetails
The field is called Username and is unique
SELECT * FROM Userdetails WHERE username = strUsername
Is this correct?
Also, in part 2 of your last response, how would I use the ADO command set?
In part 3, how would I code this?
Thanks
"Nicole Calinoiu" <nicolec@somewhere.net> wrote in message
news:Oa0elEojDHA.2512@TK2MSFTNGP09.phx.gbl...does.> Andy,
>
> For this, you don't need to query the db to find out if a row for the user
> name already exists since you need the data for the user anyway if ithere's> Since you haven't mentioned which database platform you're using, it'a wee
> bit difficult to give any details of the querying approach. However,(SQL> some general guidelines:
>
> 1. Set up a parameterized stored query (Access) or a stored procedureRecordset> Server) in the following form:
> SELECT <the columns you want to display on the form>
> FROM <your users table>
> WHERE <the user name column> = <the user name parameter>
> 2. User the ADO Command object in your user details page to execute this
> stored query/procedure, passing the user name received from the URL query
> string as the value the user name parameter, and returning an ADOyour> object.
> 3. Assuming you have a uniqueness contraint on the user name column inrow> users table, the recordset returned from step #2 will contain either oneusername> (the matching user) or no rows (indicating that it's a new user name). If
> the recordset does contain a row, use the values from the recordset fields
> to pre-populate the input elements on your form. If it doesn't contain a
> row, leave the inputs blank or give them appropriate default values.
>
> If you need help with the details of any particular aspect of this, please
> specify what exactly.
>
> HTH,
> Nicole
>
>
>
>
> "Vivista Eastbourne" <a@a.a> wrote in message
> news:3f8583b0$0$122$7b0f0fd3@mistral.news.newnet.c o.uk...> > Hi Nicole,
> >
> > Thanks for that, but how would I have the asp query the databasesto> > field in all the records and determine if that record existed?
> > Thanks Again for all your help
> > I have been racking my brains with this part of the project.
> > Cheers
> >
> > Andy G
> >
> >
> > "Nicole Calinoiu" <nicolec@somewhere.net> wrote in message
> > news:u23rUenjDHA.1488@TK2MSFTNGP12.phx.gbl...> > > Andy,
> > >
> > > In that case, instead of a link on the SCR page, you need to redirectof> > the> > > user details page after completing the save from the server-side codepage,> completing> > the> > page,> > > SCR page. Let's say that by the time of the sucessful save in the SCR> > > the user name is stored in a variable named strUserName. After> > > the save and performing any necessary clean-up activity in the SCRwith> page:> > > just use the following line of code to redirect to the user details> > >
> > > Response.Redirect "UserDetails.asp?UserName=" & strUserName
> > >
> > > This will cause a client-side redirection to the user details page,add> > the> > > target user name included in the query string.
> > >
> > > HTH,
> > > Nicole
> > >
> > >
> > >
> > >
> > > "Vivista Eastbourne" <a@a.a> wrote in message
> > > news:3f83bc15$0$125$7b0f0fd3@mistral.news.newnet.c o.uk...
> > > > Hi Nicole
> > > >
> > > > There is an add buttin on the SCR form which, when pressed, shouldand> > the> > > > SCR record to the database, then redirect to the userdetails formname> > > check
> > > > the 'username' from the SCR form in the userdetails table, if thebring> > > > exists in a record, bring up that record for updating, otherwiseyou> > up> > > > the form for a new record.
> > > >
> > > > Thanks
> > > >
> > > > Andy G
> > > >
> > > > "Nicole Calinoiu" <nicolec@somewhere.net> wrote in message
> > > > news:eLDtnlOjDHA.2076@TK2MSFTNGP09.phx.gbl...
> > > > > Andy,
> > > > >
> > > > > I think I may have understood your problem incorrectly. When doaction="userdetails_detail.asp?vusername=vusername <%=GetQueryString("Detail"> the> > > want
> > > > to
> > > > > launch the user details form? From a link on the SCR form? When> code> > Empty,> > > SCR
> > > > > form data is saved? Some other trigger point?
> > > > >
> > > > > Nicole
> > > > >
> > > > >
> > > > > "Vivista Eastbourne" <a@a.a> wrote in message
> > > > > news:3f82da5f$0$122$7b0f0fd3@mistral.news.newnet.c o.uk...
> > > > > > Hi Nicole,
> > > > > > Thanks for responding
> > > > > > I am fairly new to ASP and not fully up to speed.
> > > > > >
> > > > > > Currently after the add button is pressed, the followiung is the
> > > submit
> > > > > > code:
> > > > > > <FORM name=frmDetail method=post
> > > > > > action="SCR_detail.asp<%=GetQueryString("Detail", Empty, Empty,> > > > > > Empty)%>">
> > > > > > to follow your convention of <a
> > > > > > href="userdetails.asp?username=whatever">...</a>, I presume the>> >> > > > would
> > > > > > look like this:
> > > > > > <FORM name=frmDetail method=post
> > > > > >
> > > > >
> > > >
> > >new> page> > > > > > , Empty, Empty, Empty, Empty)%>">
> > > > > > where vusername is the variable used on both forms in asp but in
> > > > different
> > > > > > database tables, is this correct?
> > > > > >
> > > > > > Also, what code would be required in the userdetails_detail.asp> > > to
> > > > > > check if the username exists in that table?
> > > > > >
> > > > > > Thanks Again
> > > > > >
> > > > > > Andy G
> > > > > >
> > > > > > "Nicole Calinoiu" <nicolec@somewhere.net> wrote in message
> > > > > > news:uE58CVNjDHA.2076@TK2MSFTNGP09.phx.gbl...
> > > > > > > Andy,
> > > > > > >
> > > > > > > Put all the logic for determining whether your dealing witha> or> > > > > > existing
> > > > > > > user data in the user details page. In the SCR page, just usethe> > string.> > > link
> > > > to
> > > > > > the
> > > > > > > user details page that passes the SCR user name in the query> > with> > > > > > e.g.:
> > > > > > >
> > > > > > > <a href="userdetails.asp?username=whatever">...</a>
> > > > > > >
> > > > > > > In ther user details page, query the db based for data on the
> > > > specified
> > > > > > > user. If you get back any data, pre-populate all the controls> > > > data
> > > > > > on
> > > > > > > the user. If you don't get back data from the db, leave allthe> > > > > controls
> > > > > > > blank except for the user name (which you can populate withtime> > > value
> > > > > > > received from the query string).
> > > > > > >
> > > > > > > Don't bother flagging the row as an insert or update at thepage> > of> > > > the
> > > > > > > initial read from the db. Even if it's a new row when theadd> is> user> > > > > > initially
> > > > > > > loaded, it might not be by the time it's saved (i.e.: another> > > may
> > > > > > have
> > > > > > > added data against the same user name in the interim). Justa> as> > > logic
> > > > > to
> > > > > > > the code that saves the edited data to the db to update/insert> from> > > > > > necessary
> > > > > > > at the time of the actual save.
> > > > > > >
> > > > > > > HTH,
> > > > > > > Nicole
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > "Vivista Eastbourne" <a@a.a> wrote in message
> > > > > > > news:3f82b41f$0$130$7b0f0fd3@mistral.news.newnet.c o.uk...
> > > > > > > > Hi
> > > > > > > >
> > > > > > > > I have 2 tables, one called SCR and one called userdetails
> > > > > > > > SCR table contains details of a change
> > > > > > > > Userdetails contains information about a user
> > > > > > > >
> > > > > > > > All the data is entered via asp on our intranet
> > > > > > > >
> > > > > > > > One of the SCR fields is Username
> > > > > > > > One of the Userdetails fields is also Username
> > > > > > > >
> > > > > > > > Both tables currently have a seperate asp form (by request> bring> > form> > > > above)
> > > > > > > >
> > > > > > > > How can I check if the value entered for username on the SCR> > > > > exists
> > > > > > > as
> > > > > > > > a username value in the Userdetails form, and if it does,> > up> > > > the
> > > > > > > > record for that username, or if not, open up the blank form.
> > > > > > > >
> > > > > > > > Bear in mind that the forms already exist, just really need
> > > pointers
> > > > > on
> > > > > > > the
> > > > > > > > code.
> > > > > > > >
> > > > > > > > Any help is (as always) greatly appreciated
> > > > > > > >
> > > > > > > > Many Thanks if you can help (you were all newbies once upon>> >> > > time)
> > > > > > > >
> > > > > > > > Andy G
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
>
Vivista Eastbourne Guest
-
Advanced>Forms>Export Forms Data is grayed out
version 6.0.0 ¿ How do I activate this option ? -
Sharing data across web forms?
I am using Infragistics UltraWebTab (a tab folder control for ASP.NET). My tab folder control will include five tab pages with a separate web form... -
can pdf forms be used to submit data into db?
hi guys and gals, aloha from hawaii, Not sure if this is the right place to ask, but i just need to know if it is technically possible to have a... -
[PHP] can pdf forms be used to submit data into a db?
Look here: http://sk2.php.net/manual/en/ref.fdf.php Thanks you fixed the missing indefinite article, I was not going to answer the original. ... -
separating forms and data
I have an Access database with its tables, forms, macros, and data access pages in one file. This worked until now, but I need to have my clients... -
Nicole Calinoiu #2
Re: Problem with data in 2 forms: Please help
See inline...
"Vivista Eastbourne" <a@a.a> wrote in message
news:3f8d4ec1$0$127$7b0f0fd3@mistral.news.newnet.c o.uk...Not quite. First, create a stored parameter query with a SQL statement like> Hi Nicole,
> Thanks again.
>
> The Database is an Access database called userdetails.mdb
> The table is called UserDetails
> The field is called Username and is unique
>
> SELECT * FROM Userdetails WHERE username = strUsername
>
> Is this correct?
>
the following:
PARAMETERS pUserName Text ( <length of your UserName column in the
UserDetails table> );
SELECT <the fields you need for the form>
FROM UserDetails
WHERE UserName = pUserName;
set?> Also, in part 2 of your last response, how would I use the ADO command
There is an example with quite a bit of explanation at
[url]http://www.webconcerns.co.uk/asp/accessqueries/accessqueries.asp[/url]. You might
also want to take a look as the ADO documentation in the MSDN library. If
you don't have a local copy, see
[url]http://msdn.microsoft.com/library/en-us/ado270/htm/mdaobj01.asp[/url].
Once you've got your recordset open, it'll have either no records or a>
> In part 3, how would I code this?
single record. If it has a record, transfer the field values into variables
for later use. If it doesn't, set the variable values to the appropriate
default values. e.g.:
with rstUser
if .eof and .bof then
strFirstName = ""
strLastName = ""
'and so on for the rest of the variables you need...
else
strFirstName = .fields("FirstName").value
strLastName = .fields("LastName").value
'...
end if
.close 'since you shouldn't need it any more once you've captured all
the available data.
end with
When the form gets rendered, you simply write the variable values (with
appropriate HTML-encoding) into the HTML tags for your input elements.
e.g.:
If your HTML is hard-coded:
<input type=text name=FirstName value="<% Response.Write
Server.HtmlEncode(strFirstName) %>">
If you're rendering the HTML from script:
Response.Write "<input type=text name=FirstName value="""
Response.Write Server.HtmlEncode(strFirstName)
Response.Write """>"
HTH,
Nicole
user>
> Thanks
>
>
> "Nicole Calinoiu" <nicolec@somewhere.net> wrote in message
> news:Oa0elEojDHA.2512@TK2MSFTNGP09.phx.gbl...> > Andy,
> >
> > For this, you don't need to query the db to find out if a row for thewee> does.> > name already exists since you need the data for the user anyway if it> > Since you haven't mentioned which database platform you're using, it'athis> here's> > bit difficult to give any details of the querying approach. However,> (SQL> > some general guidelines:
> >
> > 1. Set up a parameterized stored query (Access) or a stored procedure> > Server) in the following form:
> > SELECT <the columns you want to display on the form>
> > FROM <your users table>
> > WHERE <the user name column> = <the user name parameter>
> > 2. User the ADO Command object in your user details page to executequery> > stored query/procedure, passing the user name received from the URLIf> Recordset> > string as the value the user name parameter, and returning an ADO> your> > object.
> > 3. Assuming you have a uniqueness contraint on the user name column in> row> > users table, the recordset returned from step #2 will contain either one> > (the matching user) or no rows (indicating that it's a new user name).fields> > the recordset does contain a row, use the values from the recordseta> > to pre-populate the input elements on your form. If it doesn't containplease> > row, leave the inputs blank or give them appropriate default values.
> >
> > If you need help with the details of any particular aspect of this,redirect> username> > specify what exactly.
> >
> > HTH,
> > Nicole
> >
> >
> >
> >
> > "Vivista Eastbourne" <a@a.a> wrote in message
> > news:3f8583b0$0$122$7b0f0fd3@mistral.news.newnet.c o.uk...> > > Hi Nicole,
> > >
> > > Thanks for that, but how would I have the asp query the databases> > > field in all the records and determine if that record existed?
> > > Thanks Again for all your help
> > > I have been racking my brains with this part of the project.
> > > Cheers
> > >
> > > Andy G
> > >
> > >
> > > "Nicole Calinoiu" <nicolec@somewhere.net> wrote in message
> > > news:u23rUenjDHA.1488@TK2MSFTNGP12.phx.gbl...
> > > > Andy,
> > > >
> > > > In that case, instead of a link on the SCR page, you need tocode> to> > > the
> > > > user details page after completing the save from the server-sideSCR> of> > > the
> > > > SCR page. Let's say that by the time of the sucessful save in theWhen> page,> > completing> > > page,
> > > > the user name is stored in a variable named strUserName. After> > > > the save and performing any necessary clean-up activity in the SCR> with> > page:> > > > just use the following line of code to redirect to the user details> > > >
> > > > Response.Redirect "UserDetails.asp?UserName=" & strUserName
> > > >
> > > > This will cause a client-side redirection to the user details page,> add> > > the
> > > > target user name included in the query string.
> > > >
> > > > HTH,
> > > > Nicole
> > > >
> > > >
> > > >
> > > >
> > > > "Vivista Eastbourne" <a@a.a> wrote in message
> > > > news:3f83bc15$0$125$7b0f0fd3@mistral.news.newnet.c o.uk...
> > > > > Hi Nicole
> > > > >
> > > > > There is an add buttin on the SCR form which, when pressed, should> and> > > the
> > > > > SCR record to the database, then redirect to the userdetails form> name> > > > check
> > > > > the 'username' from the SCR form in the userdetails table, if the> bring> > > > > exists in a record, bring up that record for updating, otherwise> you> > > up
> > > > > the form for a new record.
> > > > >
> > > > > Thanks
> > > > >
> > > > > Andy G
> > > > >
> > > > > "Nicole Calinoiu" <nicolec@somewhere.net> wrote in message
> > > > > news:eLDtnlOjDHA.2076@TK2MSFTNGP09.phx.gbl...
> > > > > > Andy,
> > > > > >
> > > > > > I think I may have understood your problem incorrectly. When do> > > > want
> > > > > to
> > > > > > launch the user details form? From a link on the SCR form?the> > the> > > > SCR
> > > > > > form data is saved? Some other trigger point?
> > > > > >
> > > > > > Nicole
> > > > > >
> > > > > >
> > > > > > "Vivista Eastbourne" <a@a.a> wrote in message
> > > > > > news:3f82da5f$0$122$7b0f0fd3@mistral.news.newnet.c o.uk...
> > > > > > > Hi Nicole,
> > > > > > > Thanks for responding
> > > > > > > I am fairly new to ASP and not fully up to speed.
> > > > > > >
> > > > > > > Currently after the add button is pressed, the followiung isEmpty,> > > > submit
> > > > > > > code:
> > > > > > > <FORM name=frmDetail method=post
> > > > > > > action="SCR_detail.asp<%=GetQueryString("Detail", Empty,the> > > Empty,
> > > > > > > Empty)%>">
> > > > > > > to follow your convention of <a
> > > > > > > href="userdetails.asp?username=whatever">...</a>, I presumeaction="userdetails_detail.asp?vusername=vusername <%=GetQueryString("Detail">> > code> >> > > > > would
> > > > > > > look like this:
> > > > > > > <FORM name=frmDetail method=post
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >in> > > > > > > , Empty, Empty, Empty, Empty)%>">
> > > > > > > where vusername is the variable used on both forms in asp butuserdetails_detail.asp> > > > > different
> > > > > > > database tables, is this correct?
> > > > > > >
> > > > > > > Also, what code would be required in theuse> new> > page> > > > to
> > > > > > > check if the username exists in that table?
> > > > > > >
> > > > > > > Thanks Again
> > > > > > >
> > > > > > > Andy G
> > > > > > >
> > > > > > > "Nicole Calinoiu" <nicolec@somewhere.net> wrote in message
> > > > > > > news:uE58CVNjDHA.2076@TK2MSFTNGP09.phx.gbl...
> > > > > > > > Andy,
> > > > > > > >
> > > > > > > > Put all the logic for determining whether your dealing with> > or> > > > > > > existing
> > > > > > > > user data in the user details page. In the SCR page, justthe> a> > > > link
> > > > > to
> > > > > > > the
> > > > > > > > user details page that passes the SCR user name in the query
> > > string.
> > > > > > > e.g.:
> > > > > > > >
> > > > > > > > <a href="userdetails.asp?username=whatever">...</a>
> > > > > > > >
> > > > > > > > In ther user details page, query the db based for data oncontrols> > > > > specified
> > > > > > > > user. If you get back any data, pre-populate all theanother> the> > > with
> > > > > data
> > > > > > > on
> > > > > > > > the user. If you don't get back data from the db, leave all> the> > > > > > controls
> > > > > > > > blank except for the user name (which you can populate with> time> > > > value
> > > > > > > > received from the query string).
> > > > > > > >
> > > > > > > > Don't bother flagging the row as an insert or update at the> page> > > of
> > > > > the
> > > > > > > > initial read from the db. Even if it's a new row when the> > is> > > > > > > initially
> > > > > > > > loaded, it might not be by the time it's saved (i.e.:update/insert> add> > user> > > > may
> > > > > > > have
> > > > > > > > added data against the same user name in the interim). Just> > > > logic
> > > > > > to
> > > > > > > > the code that saves the edited data to the db toSCR> > as> > from> > > > > > > necessary
> > > > > > > > at the time of the actual save.
> > > > > > > >
> > > > > > > > HTH,
> > > > > > > > Nicole
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > "Vivista Eastbourne" <a@a.a> wrote in message
> > > > > > > > news:3f82b41f$0$130$7b0f0fd3@mistral.news.newnet.c o.uk...
> > > > > > > > > Hi
> > > > > > > > >
> > > > > > > > > I have 2 tables, one called SCR and one called userdetails
> > > > > > > > > SCR table contains details of a change
> > > > > > > > > Userdetails contains information about a user
> > > > > > > > >
> > > > > > > > > All the data is entered via asp on our intranet
> > > > > > > > >
> > > > > > > > > One of the SCR fields is Username
> > > > > > > > > One of the Userdetails fields is also Username
> > > > > > > > >
> > > > > > > > > Both tables currently have a seperate asp form (by request> > > > > above)
> > > > > > > > >
> > > > > > > > > How can I check if the value entered for username on theform.> > bring> > > form
> > > > > > exists
> > > > > > > > as
> > > > > > > > > a username value in the Userdetails form, and if it does,> > > up
> > > > > the
> > > > > > > > > record for that username, or if not, open up the blankneed> > > > > > > > >
> > > > > > > > > Bear in mind that the forms already exist, just reallyupon> > > > pointers
> > > > > > on
> > > > > > > > the
> > > > > > > > > code.
> > > > > > > > >
> > > > > > > > > Any help is (as always) greatly appreciated
> > > > > > > > >
> > > > > > > > > Many Thanks if you can help (you were all newbies once> a>> >> > > > time)
> > > > > > > > >
> > > > > > > > > Andy G
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
>
>
>
Nicole Calinoiu Guest



Reply With Quote

