Solved

Passing Database Fields to memo boxes

Posted on 1999-01-28
2
169 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to dynamically set the form action using jQuery.

623 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