ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 23rd, 2009, 08:30 AM
MatthewPhillips MatthewPhillips is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 4 MatthewPhillips User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 33 m 19 sec
Reputation Power: 0
ASP.Net/AJAX - Creating a Page?

Hi my name is Matthew, this is my first time on this forum and you all seem so smart and fast to answer so I thought I would ask a quick question. Please feel free to move this to the appropriate area if necessary!

My question is:
I am creating a Content Managment System in .ASP and Microsoft Database 2003.

I I have got down how to add text to database and delete text from database (and of course show text from data base), but I cant seem to figure out how to edit text that is currently in the database (while on the website). Any help would be greatly appreciated. (currently I have to delete the record and re add it witch can be very time consuming.)

Also I am trying to figure out how to add a new page to the website. With out having a url like the following

domain/pages.asp?PageId=01

I would like it to look like this

domain/Page_01

Any help would be great fully appreciated.

Reply With Quote
  #2  
Old March 23rd, 2009, 06:25 PM
bigmike1212's Avatar
bigmike1212 bigmike1212 is offline
Option Explicit, baby.
ASP Free Novice (500 - 999 posts)
 
Join Date: Jan 2009
Location: Neighborhood of Make-Believe
Posts: 554 bigmike1212 User rank is First Lieutenant (10000 - 20000 Reputation Level)bigmike1212 User rank is First Lieutenant (10000 - 20000 Reputation Level)bigmike1212 User rank is First Lieutenant (10000 - 20000 Reputation Level)bigmike1212 User rank is First Lieutenant (10000 - 20000 Reputation Level)bigmike1212 User rank is First Lieutenant (10000 - 20000 Reputation Level)bigmike1212 User rank is First Lieutenant (10000 - 20000 Reputation Level)bigmike1212 User rank is First Lieutenant (10000 - 20000 Reputation Level)bigmike1212 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 17 h 55 m 27 sec
Reputation Power: 146
Quote:
Originally Posted by MatthewPhillips
Hi my name is Matthew, this is my first time on this forum


Welcome.

Quote:
Originally Posted by MatthewPhillips
I have got down how to add text to database and delete text from database (and of course show text from data base), but I cant seem to figure out how to edit text that is currently in the database (while on the website).


Well, without seeing any code, I am going to guess you are adding text with an SQL INSERT statement and deleting it with a DELETE statement.

The next one you want to look at is the UPDATE statement. Do a query, display the fields of the record you are interested in by prepopulating some form elements, edit the values in the form elements, let your form action hit an asp page that has an update statement.

Look through this:

http://www.codefixer.com/tutorials/news_management_system_part1.asp

probably part 7 for you.

Reply With Quote
  #3  
Old March 23rd, 2009, 06:34 PM
MatthewPhillips MatthewPhillips is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 4 MatthewPhillips User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 33 m 19 sec
Reputation Power: 0
I posted the whole code for my AnnouncmentAdmin.asp page

all my scripting for the add and delete is held in this page

but im really not sure what you mean be the update statement.

At times I have as many as 10 announcements can I edit them all or just one?

And also if you need to know I use microsoft access 2003 databases .mde or .mdb

Quote:
Originally Posted by bigmike1212
Welcome.



Well, without seeing any code, I am going to guess you are adding text with an SQL INSERT statement and deleting it with a DELETE statement.

The next one you want to look at is the UPDATE statement. Do a query, display the fields of the record you are interested in by prepopulating some form elements, edit the values in the form elements, let your form action hit an asp page that has an update statement.

Look through this:



probably part 7 for you.

Reply With Quote
  #4  
Old March 24th, 2009, 12:19 AM
icywave icywave is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Sep 2005
Location: Global Village
Posts: 719 icywave User rank is Sergeant Major (2000 - 5000 Reputation Level)icywave User rank is Sergeant Major (2000 - 5000 Reputation Level)icywave User rank is Sergeant Major (2000 - 5000 Reputation Level)icywave User rank is Sergeant Major (2000 - 5000 Reputation Level)icywave User rank is Sergeant Major (2000 - 5000 Reputation Level)icywave User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 5 Days 4 h 15 m 41 sec
Reputation Power: 52
Send a message via MSN to icywave
You're missing a lot here. I can't really explain in detail because there's simply too much to cover, go over some tutorials on recordsets and updating an database.

The concept is like this. You pull out information from the database, then display it in a form. Then the user can edit the information in the form, and submit the page, the page then UPDATES the database, replacing the old information with the new ones. You can do multiple edits in one page yes, but first make sure that you have all of the basics down.

You should also consider security and try to prevent unsafe characters. It's hard developing a content management system when you're just starting to code.

Good luck anyways.
You can always get all of the help you want on here. =)
__________________
Why Captcha Images Are EVIL!


For more interesting reads, visit 3Or2-3.

Reply With Quote
  #5  
Old March 24th, 2009, 08:02 AM
MatthewPhillips MatthewPhillips is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 4 MatthewPhillips User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 33 m 19 sec
Reputation Power: 0
I'm not really sure what you mean by I am missing a lot? And I also don't understand why you think I am a beginner Programmer. Since most of you and most tutorials tell people to do what I have written in 1 page in 4 pages so....

I think I have a pretty good Idea on how to do this thank you all for the help.



Quote:
Originally Posted by icywave
You're missing a lot here. I can't really explain in detail because there's simply too much to cover, go over some tutorials on recordsets and updating an database.

The concept is like this. You pull out information from the database, then display it in a form. Then the user can edit the information in the form, and submit the page, the page then UPDATES the database, replacing the old information with the new ones. You can do multiple edits in one page yes, but first make sure that you have all of the basics down.

You should also consider security and try to prevent unsafe characters. It's hard developing a content management system when you're just starting to code.

Good luck anyways.
You can always get all of the help you want on here. =)

Reply With Quote
  #6  
Old March 24th, 2009, 09:03 AM
mystic7's Avatar
mystic7 mystic7 is offline
Contributing User
Click here for more information.
 
Join Date: Sep 2006
Posts: 1,502 mystic7 User rank is Captain (20000 - 30000 Reputation Level)mystic7 User rank is Captain (20000 - 30000 Reputation Level)mystic7 User rank is Captain (20000 - 30000 Reputation Level)mystic7 User rank is Captain (20000 - 30000 Reputation Level)mystic7 User rank is Captain (20000 - 30000 Reputation Level)mystic7 User rank is Captain (20000 - 30000 Reputation Level)mystic7 User rank is Captain (20000 - 30000 Reputation Level)mystic7 User rank is Captain (20000 - 30000 Reputation Level)mystic7 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 12 h 53 m 9 sec
Reputation Power: 292
Glad we could be of assistance.

Reply With Quote
  #7  
Old March 24th, 2009, 08:41 PM
icywave icywave is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Sep 2005
Location: Global Village
Posts: 719 icywave User rank is Sergeant Major (2000 - 5000 Reputation Level)icywave User rank is Sergeant Major (2000 - 5000 Reputation Level)icywave User rank is Sergeant Major (2000 - 5000 Reputation Level)icywave User rank is Sergeant Major (2000 - 5000 Reputation Level)icywave User rank is Sergeant Major (2000 - 5000 Reputation Level)icywave User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 5 Days 4 h 15 m 41 sec
Reputation Power: 52
Send a message via MSN to icywave
Good luck with your project. =)

Just as a reminder, be sure to check for bugs and prevent hackers...

Reply With Quote
  #8  
Old March 25th, 2009, 02:13 AM
keep_it_simple's Avatar
keep_it_simple keep_it_simple is offline
KIS
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Jul 2007
Location: USA
Posts: 1,536 keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 20 h 53 m 22 sec
Reputation Power: 845
Send a message via Yahoo to keep_it_simple
Quote:
And I also don't understand why you think I am a beginner Programmer. Since most of you and most tutorials tell people to do what I have written in 1 page in 4 pages so....


the fact you are a new to the forum and you asked a basic question that most experienced programmers would know - how to update a database

the demo is based on mikes post...

you get a stylesheet, full html code, hyperlinks, a (display, add, update, delete form), and code to (add, delete,update)...all rolled into ONE page...not 4

demo: click me


Code:

<html>
 <head>
  <style>
   body {text-align:center;font-family:arial;font-size:12px;}
   table {width:400px;font-size:12px;border:1px solid #333;} 
   input.box {width:100%;font-size:12px;}
   td {background:#FCFCFC;border:1px solid #EDEDED;}
   td.add {padding:5px;}
   td.ck {text-align:center;}
   th  {background:#333;color:white;padding:2px;}
   caption {text-align:left;font-weight:bold;font-size:14px;}
  </style>
 </head>
 <body>

<%
  sAction = Request.Form("action")
  sLink = Request.QueryString("type")
  sAct = Request.Form("act")
  sAIDs = Trim(Replace(Request.Form("aid")," ",""))
  sPage = Request.ServerVariables("SCRIPT_NAME")
  aLinks = Array("Add","Delete","Update","Display")

  Function ReturnRS
   Set oRs = oConn.Execute("SELECT * FROM tAs;")   
   If Not oRs.EOF Then ReturnRS = oRs.GetRows
  End Function 

  Function SanitizeString(sString)
   If Len(sString) > 0 Then
    SanitizeString = Trim(Replace(sString,"'","''"))
   End If
  End Function

  Function OpenDatabase
   Set oConn = Server.CreateObject("ADODB.Connection")
   oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
              "Data Source=" & Server.MapPath("db/ats.mdb") & ";"
  End Function

  Dim oConn
  OpenDatabase

  For each item in aLinks
   Response.Write "<a href=""" & sPage & "?type=" & item & """>" & item & "</a> "
  Next

  If Len(sAction) > 0 Then  
   Select Case sAction
    Case "Add"
     oConn.Execute("INSERT INTO tAs (Act) VALUES('" & SanitizeString(sAct) & "');")
    Case "Delete"
     oConn.Execute("DELETE * FROM tAs WHERE AID IN (" & sAIDs & ");") 
    Case "Update"
     For each item in Request.Form     
      sAct = Request.Form(item)
      iAID = Replace(item,"a_","")
      
      If Left(item,2) = "a_" Then     
       oConn.Execute("UPDATE tAs SET Act='" & SanitizeString(sAct) & "' WHERE AID=" & iAID & ";")
      End If
     Next
   End Select
  End If

  aActs = ReturnRS 
  bRS = isArray(aActs)
  If sLink = "" Then sLink = "Display"

  If bRS OR sLink = "Add" Then
   Response.Write "<form action=""" & sPage & """ method=""post"">"  & _
                 "<table><caption>" & sLink & " Form</caption></tr>"

   Select Case sLink
    Case "Add"
     Response.Write "<tr><th colspan=""2"">Announcement</th></tr>" & _
                    "<tr><td class=""add""><input class=""box""name=""act""></td></tr>" & _
                    "<tr><td class=""add"" align=""center""><input type=""submit"" name=""action"" maxlength=""50"" value=""Add""></td></tr>"
    Case "Delete"
     Response.Write "<tr><th>Announcement</th><th>Select</th></tr>"
     For i = 0 to UBound(aActs,2)
      Response.Write "<tr><td>" & aActs(1,i) & "</td>" & _
                     "    <td class=""ck""><input name=""aid"" type=""checkbox"" value=""" & aActs(0,i) & """></td>" & _                 
                     "</tr>"
     Next
     Response.Write "<tr><td colspan=""2"" align=""center""><input type=""submit"" name=""action"" value=""Delete""></td></tr>"
    Case "Update"
     Response.Write "<tr><th>Announcement</th></tr>"
     For i = 0 to UBound(aActs,2)
      Response.write "<tr><td><input class=""box"" name=""a_" & aActs(0,i) & """ value=""" & aActs(1,i) & """></td></tr>"
     Next
     Response.Write "<tr><td align=""center""><input type=""submit"" name=""action"" value=""Update""></td></tr>"
    Case Else
     Response.Write "<tr><th>Announcements</th></tr>"
     For i = 0 to UBound(aActs,2)
      Response.Write "<tr><td>" & aActs(1,i) & "</td></tr>"
     Next    
   End Select

   Response.Write "</table></form>"
  Else
   Response.Write "<h3>No records</h3>"
  End If  
%>

 </body>
</html>
__________________
Please give respect to those that helped solve an issue by clicking on the reputation icon

Last edited by keep_it_simple : March 25th, 2009 at 02:19 AM. Reason: added demo

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > ASP.Net/AJAX - Creating a Page?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek