Solved

Passing Database Fields to memo boxes

Posted on 1999-01-28
2
167 Views
Last Modified: 2013-12-25
I have an Access Database Table with a Comments field in it that I wish people to be able to amend via a web page.

When someone opens the update page, it will have a text box for people to enter new comments.  I know nothing about ASP except the Database Region Wizard that comes with Frontpage 98.  How can I pass the current information from the comments field in the database to the text box, to save either overwriting the data each time, or having the user enter the current data as well as the new data?

Please try and keep it simple, as my knowledge of ASP is very limited.

Thanks for any help that anyone can give me.
0
Comment
Question by:balabaster
  • 2
2 Comments
 
LVL 6

Accepted Solution

by:
PBall earned 100 total points
ID: 1859266
1. Retrieve the data using ASP before displaying it.

<%
  Set rs = Server.CreateObject("ADODB.Recordset")
  rs.Open "SELECT * FROM tablename WHERE fieldname = ....","dsn_name"
%>

2. Insert the following in between the <TEXTAREA></TEXTAREA>:

<TEXTAREA .....><%=rs("memo_field_name")%></TEXTAREA>

3. close the recordset somewhere near the end of the ASP file after you have retrieve all the data that you need from it.

<%
   rs.Close
   Set rs = Nothing
%>


Full sample:

<%
  'Get the date from previous form field called DateID.
  PickedDate = Request("DateID")

  if Len(PickedDate) < 1 Then
  'Default to current server date if there is non passed.
    PickedDate = Date
  else
  'Otherwise, make it official (change to datetime type)
    PickedDate = cDate(PickedDate)
  end if

  Set rs = Server.CreateObject("ADODB.Recordset")
  rs.Open "SELECT * FROM Diary WHERE Timestamp = '" & PickedDate & "'","dsnDiary"
%>
<html>
<head>
<title>Edit Diary</title>
</head>
<body>
<form name=frmEdit action='edit2.asp' method=post>
Timestamp: <%=PickedDate%><br>
Entry:
<textarea name=txtEntry wrap=virtual row=10 col=40><%
   'if recordset return something, show the record
   if Not (rs.BOF And rs.EOF) then
     Response.Write rs("Entry")
   end if
%></textarea><br>
<input type=submit name=btnNav value='Save Changes'>
<input type=submit name=btnNav value='Cancel Changes'>
</form>
</body>
</html>
<%
  rs.Close
  Set rs = Nothing
%>
0
 
LVL 6

Expert Comment

by:PBall
ID: 1859267
Some weird thing about text field (at least in SQL Server), they have to be displayed in order of appearance (at least from my experiences)

i.e.  you have 2 text fields, one called Blah and the other called Yuck.

if you retrieve it as SELECT Blah, Yuck FROM Ugh

you have to display Blah first and then Yuck and not the other way around, because it will caused an error.

I usually retrieve multiple text fields into variables and display the variables instead (in whichever order I want), as long as I retrieved it in the order of appearance, they seemed to work just fine :)

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question