Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 25th, 2004, 11:50 PM
Authorized User
 
Join Date: Feb 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to sinner
Default APPENDING TO A RECORD

Hello all,

Is there a way to append to a record (add to it, not overwrite it)???
I am currently working on a VERY simple ticketing system and one of my fields is a comment box (text box form). I need to be able to append to the end of the text entered by user. The rest of the fileds can overwirte as they are always the same.
Is this a "good" way of doing it or should I send it to a text file??? Any help/ideas would be greatly appreciated.

 
Old February 26th, 2004, 04:19 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Yeah, you can easily append to the field. If you're using SQL statements for the update, try something like this:

UPDATE MyTable SET MyColumn = MyColumn + ' My New Value' WHERE MyTable.ID = 123

This will append the text My New Value to the text present in the MyColumn field for the record whose ID = 123.

Does this help? If not, can you post some of the code you already have?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old April 4th, 2004, 08:19 PM
Authorized User
 
Join Date: Feb 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to sinner
Default

Hey guys,

I am trying to update a recordset that I display here, but have no idea how.

The form on the bottom is for updateing the commends field but i have no idea what the synthax should be.

I tried something like this but no luck:

<%
ConnString = "DSN=ticketbackup"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open ConnString,,,adOpenForwardOnly
Set rs = SERVER.CreateObject("ADODB.Recordset")

strSQL = "UPDATE ticket SET Comments = Comments + '"& request.form("upComments")&"' WHERE ticket.ID = rs.fields("Ticket_ID")"


rs.Open strSQL,conn, adOpenStatic



Following is the code for the entire page. Any help wou8ld be greatly appreciated



<html>

<head>
<title>View Trace Tickets</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
</head>

<body bgcolor="#000080">

<p align="center"><br>
</p>

<p align="center">&nbsp;</p>
<%
ConnString = "DSN=ticketbackup"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open ConnString,,,adOpenForwardOnly
Set rs = SERVER.CreateObject("ADODB.Recordset")

strSQL = "SELECT * FROM ticket WHERE Ticket_type = 'OPEN' ORDER BY PSAP "

rs.Open strSQL,conn, adOpenStatic

%>

<form name="openedticket">
  <p><select name="open" size="1">
    <option value="NULL">LIST OF OPEN TICKETS BY PSAP</option>
<% Do While Not rs.EOF
                                    Response.Write ("<OPTION value='"& rs("PSAP") & "' >" & rs("PSAP") & "</option> ")
                                    rs.MoveNext
                                Loop
                                rs.Close
                                Set rs=Nothing %> </select><input type="submit" value="View">&nbsp;&nbsp;&nbsp; </p>
</form>

<p>&nbsp;</p>
<%
 Set rs = SERVER.CreateObject("ADODB.Recordset")

     strST=Request.QueryString("open")
     strSQL = "SELECT * FROM ticket WHERE PSAP = '" & strST & "'"

    ' Open Recordset Object
    rs.Open strSQL,conn,adOpenStatic


%>

<table border="1" width="100%">
  <tr>
    <td width="17%" bgcolor="#000080"><strong>Agency Name:</strong></td>
    <td width="83%"><%= rs.fields("PSAP") %> </td>
  </tr>
  <tr>
    <td width="17%" bgcolor="#000080"><strong>Ticket ID:</strong></td>
    <td width="83%"><%= rs.fields("Ticket_ID") %> </td>
  </tr>
  <tr>
    <td width="17%" bgcolor="#000080"><strong>Date Submitted </strong></td>
    <td width="83%"><%= rs.fields("Date_open") %> </td>
  </tr>
  <tr>
    <td width="17%" bgcolor="#000080"><strong>Time Submitted</strong></td>
    <td width="83%"><%= rs.fields("Time_open") %> </td>
  </tr>
  <tr>
    <td width="17%" bgcolor="#000080"><strong>Contact Number:</strong></td>
    <td width="83%"><%= rs.fields("Contact") %> </td>
  </tr>
  <tr>
    <td width="17%" bgcolor="#000080"><strong>Badge/Name:</strong></td>
    <td width="83%"><%= rs.fields("Badge") %> </td>
  </tr>
  <tr>
    <td width="17%" bgcolor="#000080"><strong>Trunk Number:</strong></td>
    <td width="83%"><%= rs.fields("Trunk") %> </td>
  </tr>
  <tr>
    <td width="17%" bgcolor="#000080"><strong>Reason for Request:</strong></td>
    <td width="83%"><%= rs.fields("Reason") %> </td>
  </tr>
  <tr>
    <td width="17%" bgcolor="#000080"><strong>Comments:</strong></td>
    <td width="83%"><%= rs.fields("Comments") %> </td>
  </tr>
</table>

<p>&nbsp;</p>

<form method="POST" action="--WEBBOT-SELF--">
<div align="center"><center><p><textarea rows="10" name="upComments" cols="60"></textarea><input
  type="submit" value="Update" name="B1"><input type="reset" value="Reset" name="B2"></p>
  </center></div>
</form>
</body>
</html>


 
Old April 5th, 2004, 01:15 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

It would be useful if you'd describe what went wrong. Merely dumping your code with a "can you figure out the problem" is probably not going to work well.

Is this problem related to your initial post?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old June 2nd, 2004, 01:17 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

Try this.

TicketId = request("TicketId")
Comments = request("Comments")

set rs = server.createobject("adodb.recordset")
sql = "select * from Ticket"
sql = sql & " where Ticket.Id = " & TicketId
rs.open sql, cn, 3, 3

    if rs.eof then
        rs.addnew
        rs("Id") = TicketId
    end if
        rs("Comments") = Comments
        rs.update





Similar Threads
Thread Thread Starter Forum Replies Last Post
Appending Files indupriyav Other Programming Languages 0 March 12th, 2008 05:57 AM
Appending values austinf XSLT 2 May 9th, 2006 11:21 PM
Help in appending a single record. prashanthmcr SQL Language 0 December 14th, 2005 08:47 PM
appending to nested array asinning Beginning PHP 1 March 2nd, 2005 10:38 AM
Appending to a TextFile jfleming SQL Server DTS 3 June 16th, 2004 08:45 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.