Solved

Passing Database Fields to memo boxes

Posted on 1999-01-28
2
160 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now