Home | Advertising Info6 USERS CURRENTLY ONLINE   
PowerASP
   Site Search Contact Us Thursday, January 16, 2025  

  Active InfoActive Info  Display List of Info MembersMemberlist  Search The InfoSearch  HelpHelp
  RegisterRegister  LoginLogin
Classic ASP - Database Issues
 PowerASP Code Help Area : Classic ASP - Database Issues
Subject Info: Problem reading one db and writing to ano A d d  -  P o s tAdd P o s t
Author
Message << Prev Info | Next Info >>
shadowspell
Newbie
Newbie
Avatar

Joined: May/04/2004
Location: United States
Online Status: Offline
Info: 13
Added: May/04/2004 at 11:17am | IP Logged Quote shadowspell

I have a simple form that collegues use to submit 'names' and 'descriptions'. Upon submit, this is written to an Access db called 'NOM'.

I use another form that reads 'NOM' and populates itself with those 'names' and 'descriptions' with a radio button next to each name.

One vote is submitted via this form by clicking the radio button next to the name of the person they wish to vote for then clicking the submit button.

Upon submission of this vote, the results are written to another Access database called, 'VOTE'. But in every case, instead of one description being captured with the vote, all the descriptions from the 'NOM' db are being captured.

How can I capture the one description that goes with the name of the person being voted for?



__________________
~`^%
In Vino Veritas
Back to Top View shadowspell's Profile Search for other info by shadowspell
 
cwilliams
Admin Group
Admin Group
Avatar

Joined: April/26/2004
Location: United States
Online Status: Offline
Info: 137
Added: May/05/2004 at 2:39pm | IP Logged Quote cwilliams

Would need to see all the code involved to possibly help...

__________________


Chris Williams
http://www.PowerASP.com
Back to Top View cwilliams's Profile Search for other info by cwilliams
 
shadowspell
Newbie
Newbie
Avatar

Joined: May/04/2004
Location: United States
Online Status: Offline
Info: 13
Added: May/05/2004 at 2:54pm | IP Logged Quote shadowspell

Hi C,

I would be glad to provide the code, but it's long, almost 400 lines.
I have made a change since I posted this. Instead of two databases, I went with one database with 2 tables. That's the only change I've made.
See the code below::

------------------------------------------------------------ ---------------------------------

<%option explicit%>
<%DIM ErrorMsg,peernom,submit_date,email,firstname,lastname,fullna me,reason,sIPAddress%>
<%

' if there is an apostrophe in the user's input then this function should prevent an error upon submission
' insert this function at the point where you write a field value to the database
' for example: SQLstmt = SQLstmt & "'" & InsertAP(request("reason")) & "'"
' where "reason" is the fieldname where the value may contain an "'" entered by the user.     
Function InsertAP(t)
    If Not IsNull(t) Then
        InsertAP = Replace(t, "'", "''")
    Else
        InsertAP = ""
    End If
End Function

' GRAB THE IP ADDRESS OF USER AND STORE IT
sIpAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If sIPAddress = "" Then sIPAddress = Request.ServerVariables("REMOTE_ADDR")
sIPAddress = trim(sIPAddress)

' GRAB THE CURRENT DATE AND TIME AND STORE IT
 submit_date = now()

' The number of user-input fields in 'numFields' to error check.
 const numFields = 2
 
' Define error Array for the fields to error-check. 
 dim errorArray()
 redim preserve errorArray(numFields) 

' These variables are defined for the errorArray() to populate 'ErrorMsg' in the event of user omission of those fields.
 if request.form("isSubmitted") = "yes" then
     email = request.form("email")
  fullname = request.form("fullname")
 
  ErrorMsg = ""
  dim re
  set re = New RegExp
 
  'Email Address
  re.Pattern = "^([a-zA-Z0-9_-])+([.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+([.a-zA-Z0-9_-]+)+"
  errorArray(0) = re.Test(email)
  if errorArray(0) then
   errorArray(0) = False
  else
   errorArray(0) = True
   ErrorMsg = ErrorMsg & "* Provide your email address to receive your <br>confirmation email. Your vote is confidential.<br>"
  end if
  
  ' Name of employee
  if fullname = "" then
   errorArray(1) = True
   ErrorMsg = ErrorMsg & "* Please vote for a nominee.<br>"
  end if
    
 end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>ICS Peer Recognition - Voting Form</title>
<META NAME="MSSmartTagsPreventParsing" content="TRUE">
<script language="JavaScript" type="text/javascript">
<!--
 var root_folder = "";
 var img_folder = root_folder + "http://interconnection.bls.com/images/";
 var shared_folder = root_folder + "http://interconnection.bls.com/shared/";

// check dhtml, platform, etc.
 var isDHTML = (document.layers || document.all) ? 1 : 0;
 var isNavigator = (navigator.appName.indexOf("Netscape") >= 0) ? 1 : 0;
 var isWindows = (navigator.appVersion.indexOf("Win") >= 0) ? 1 : 0;

 var docObj = (isNavigator) ? 'document.' : 'document.all.';
 var styleObj = (isNavigator) ? '' : '.style';
//-->
</script>
<!-- layer javascript link. includes add'l methods for ie or ns -->
<script language="JavaScript1.1" type="text/javascript" src="/shared/layerAPI.js"></SCRIPT>
<!-- menuAPI javascript link, includes actions for menus -->
<script language="JavaScript1.1" type="text/javascript" src="/shared/menuAPI.js"></SCRIPT>
<!-- menus javascript link, includes actual menu content -->
<script language="JavaScript1.1" type="text/javascript" src="/shared/menus.js"></SCRIPT>
<!-- stylesheet link --->
<link rel="stylesheet" href="/shared/estyles.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="preloadImages(); add_methods(); initMouse();" link="#0066CC" vlink="#666666" alink="#3399ff" text="#000000">
<!-- menu layer -->
<!-- main body table -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="2%"><img src="/images/spacer.gif" width=10 height=20></td>
    <td class="page-title" width="98%">ICS Peer Recognition - <font color="#FF0000">Voting</font>
      Form</td>
  </tr>
</table>
<img src="/images/spacer.gif" width=20 height=20>
<table width="740" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="bottom">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><img src="/images/spacer.gif" width="8" height="23"></td>
          <td width="99%"><a href="#" class="home">HOME</a></td>
        </tr>
      </table>
    </td>
    <td><img src="/images/spacer.gif" width=10 height=10></td>
    <td>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <!-- top line of header -->
          <td><img src="/images/spacer.gif" width="1" height="1"></td>
          <td><img src="/images/box_toplineleft.gif" width="9" height="1"></td>
          <td width="2000" bgcolor="#660099"><img src="/images/spacer.gif" width="1" height="1"></td>
          <td><img src="/images/box_toplineright.gif" width="9" height="1"></td>
          <td><img src="/images/spacer.gif" width="1" height="1"></td>
        </tr>
        <tr>
          <!-- main row of header -->
          <td valign="top" bgcolor="#660099"><img src="/images/box_topedge.gif" width="1" height="23"></td>
          <td valign="top" background="/images/purple_background.gif"><img src="/images/box_topleft.gif" width="9" height="9"></td>
          <td width="2000" class="box_title" background="/images/purple_background.gif">
             <!-- article title -->
             You may vote once</td>
          <td valign="top" background="/images/purple_background.gif"><img src="/images/box_topright.gif" width="9" height="9"></td>
          <td valign="top" bgcolor="#660099"><img src="/images/box_topedge.gif" width="1" height="23"></td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td bgcolor="#660099"><img src="/images/spacer.gif" width=150 height=1></td>
    <td bgcolor="#660099"><img src="/images/spacer.gif" width=10 height=1></td>
    <td bgcolor="#660099"><img src="/images/spacer.gif" width=580 height=1></td>
  </tr>
  <tr>
    <td valign="top">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td bgcolor="#660099"><img src="/images/spacer.gif" width="16" height="2"></td>
          <td width="99%"><img src="/images/spacer.gif" width="134" height="2"></td>
        </tr>
      </table>
      </td>
    <td><img src="/images/spacer.gif" width="10" height="10"></td>
    <td valign="top">
      <table border="0" cellspacing="0" cellpadding="0" width="100%">
        <tr>
          <td bgcolor="#660099"><img src="/images/spacer.gif" width="1" height="1"></td>
          <td width="578" valign="top">
             <!-- begin content tables -->
             <table border="0" cellspacing="0" cellpadding="0" width="100%">
               <tr>
                 <td><img src="/images/spacer.gif" width="10" height="10"></td>
                 <td width="1000" valign="top">
                   <!------------ display errors if any ------>
                   <%if ErrorMsg <> "" then %>
                   <font color="red" size="2"> <%= ErrorMsg %> </font>
                   <%end if %>
                   <table border=0 cellpadding=5 cellspacing=0 width="460" height="0">
                     <tr>
                        <td colspan=2 valign="top">
                           <!------------------ FORM BEGINS HERE ------------>
                           <form name="peer_recog_vote" method="post">
                             <table width="100%" border="0" cellspacing="0" cellpadding="5">
                               <tr align="left">
                                 <td valign="middle" colspan="2"><b></b><span class="redbolditalic">*</span>
                                   <% if errorArray(0) = True then %>
                                   <font color="red"><b>
                                   <% end if %>
                                   Your email address:
                                   <% if errorArray(0) = True then %>
                                   </b></font>
                                   <% end if %>
                                   <br>
                                   <input name="email" value="<%= email %>" size="55" maxlength="55">
                                 </td>
                               </tr>
                               <%' Read the file.
        DIM Conn,strConn,SQLstmt,RS
        Set Conn = Server.CreateObject("ADODB.Connection")
        Set RS = Server.CreateObject("ADODB.RecordSet")
        strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("gptw.mdb")
        Conn.Open strConn
        SQLstmt = "SELECT * from tbl_peernominees"
        RS.Open SQLstmt, Conn, 2, 3
         Do while NOT RS.EOF %>
                               <tr align="left">
                                 <td valign="middle" colspan="2">
                                   <% if errorArray(1) = True then %>
                                   <font color="red"><b>
                                   <% end if %>
                                   <b>Name of nominee:</b><br>
                                   <%= RS("firstname")&" "& RS("lastname") %>
                                   <% if errorArray(1) = True then %>
                                   </b></font>
                                   <% end if %>
                                   <input type = "radio" name="fullname" value="<%= RS("firstname") &" "& RS("lastname") %>">
                                 </td>
                               </tr>
                               <tr align="left">
                                 <td valign="middle" colspan="2"><b>Reason employee
                                   was nominated:</b><br>
                                   <textarea name="reason" cols="55" rows="3" value="<%= RS("reason") %>"><%= RS("reason") %></textarea>
                                 </td>
                               </tr>
                               <tr>
                                 <td>
                                   <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                       <tr>
                                         <td bgcolor="#660099"><img src="/images/spacer.gif" height="1" width="100%"></td>
                                       </tr>
                                   </table>
                                 </td>
                               </tr>
                               <% RS.MoveNext
           loop %>
                               <tr align="left">
                                 <td valign="middle" colspan="2">
                                   <input type="submit" value="Submit">
                                   <input type="hidden" name="isSubmitted" value="yes">
                                   <input type="reset" value="Reset">
                                 </td>
                               </tr>
                             </table>
                           </form>
                           <!---------------------------------- FORM ENDS HERE ------------------->
                           <!------------ form is submitted, now check errorArray() for errors and display them -->
                           <%if request.form("isSubmitted") = "yes" then%>
                           <%
response.cookies("peernom_cookie") = request.form("fullname")
DIM all,e
all=False
For e=0 to 2
all=all OR CBOOL(errorArray(e))
Next
If Not all Then
email = request.form("email")
fullname = request.form("fullname")
reason = request.form("reason")
%>
                           <%
'This sends an email to Web Developer/Designer
Dim str
str = "***************************************************" & vbCrLf
str = str &"--------- ATTENTION:Peer Recognition ~ Vote ~ -----" & vbCrLf
str = str &  "****************************************************" & vbCrLf & vbCrLf
str = str &  "Information Submitted by: " & vbCrLf
str = str &  email & vbCrLf
str = str &  "on " & submit_date & vbCrLf & vbCrLf
str = str &  "from IP Address: " & sIPAddress & vbCrLf & vbCrLf
str = str &  "Person voted for: " & fullname & vbCrLf & vbCrLf
str = str &  "Reason: " & reason
 

Dim myMail
Set myMail = CreateObject("CDONTS.NewMail")
myMail.From = email
myMail.To = "wmag@bellsouth.com"
myMail.Subject = "ATTENTION: Peer Recognition Vote"
myMail.Body = str
myMail.Send
Set myMail = Nothing
' end code for sending email notification to Web Developer/Designer
%>
                           <%
'THIS IS THE EMAIL THAT GOES TO THE USER WHO FILLED OUT THE FORM
Dim str2
str2 = "*********************************************************** *********" & vbCrLf
str2 = str2 & "<< Thank you for participating in the Peer Recognition Voting >>" & vbCrLf
str2 = str2 & "*********************************************************** *********" & vbCrLf & vbCrLf
str2 = str2 &  "Here is the result of your vote" & vbCrLf
str2 = str2 &  "on " & submit_date & vbCrLf & vbCrLf
str2 = str2 &  "Person you voted for: " & fullname & vbCrLf & vbCrLf
str2 = str2 &  "Reason: " & reason

 

Dim myMail2
Set myMail2 = CreateObject("CDONTS.NewMail")
myMail2.From = "wmag@bellsouth.com"
myMail2.To = email
myMail2.Subject = "Thank you for voting for your Peer"
myMail2.Body = str2
myMail2.Send
Set myMail2 = Nothing
' end code for sending email confirmation to person who filled out the form
%>
                           <!-- begin database writing code -->
                           <%
' define 'fullname' and 'fullreason' using InsertAP function to remove
' extra single quotes " ' " before writing to database.
  fullname = InsertAP(request.form("fullname"))
  reason = InsertAP(request.form("reason"))

  SQLstmt = "INSERT INTO tbl_peervotes (submit_date,sIPAddress,email,fullname,reason)"
  SQLstmt = SQLstmt & " VALUES ("
        SQLstmt = SQLstmt & "'" & submit_date & "',"
  SQLstmt = SQLstmt & "'" & sIPAddress & "',"
  SQLstmt = SQLstmt & "'" & email & "',"
  SQLstmt = SQLstmt & "'" & fullname & "',"
  SQLstmt = SQLstmt & "'" & reason &"'"
  SQLstmt = SQLstmt & ")"
   Set RS = conn.execute(SQLstmt)
   If err.number>0 then
      response.write "VBScript Errors Occured:" & "<P>"
      response.write "Error Number=" & err.number & "<P>"
      response.write "Error Descr.=" & err.description & "<P>"
      response.write "Help Context=" & err.helpcontext & "<P>"
      response.write "Help Path=" & err.helppath & "<P>"
      response.write "Native Error=" & err.nativeerror & "<P>"
      response.write "Source=" & err.source & "<P>"
     end if
     IF conn.errors.count> 0 then
      response.write "Database Errors Occured" & "<P>"
      response.write SQLstmt & "<P>"
      for counter= 0 to conn.errors.count
       response.write "Error #" & conn.errors(counter).number & "<P>"
       response.write "Error desc. -> " & conn.errors(counter).description & "<P>"
      next
     else
  Response.Redirect("nominate_response.asp?updated =true")
  
 end if
end if
end if
%>
                           <!-- end database writing code -->
                        </td>
                     </tr>
                   </table>
                   </td>
                 <td><img src="/images/spacer.gif" width="10" height="10"></td>
                 <!-- cell with photo - to remove photo, just delete the line below -->
                 <td valign="top">&nbsp;</td>
               </tr>
             </table>
             <!-- insert additional content tables (if any) here -->
          </td>
          <td bgcolor="#660099"><img src="/images/spacer.gif" width="1" height="1"></td>
        </tr>
      </table>
      <!-- footer table -->
      <table cellspacing=0 cellpadding=0 width="100%" border=0>
        <tbody>
        <tr>
          <td valign=bottom bgcolor=#660099><img height=9
             src="/images/box_btmedges.gif" width=1></td>
          <td valign=bottom><img height=9
             src="/images/box_btm_left.gif" width=9></td>
          <td valign=bottom width=2000><img height=1
             src="/images/spacer.gif" width=1></td>
          <td valign=bottom><img height=9
             src="/images/box_btm_right.gif" width=9 img></td>
          <td valign=bottom bgcolor=#660099><img height=9
             src="/images/box_btmedges.gif" width=1></td>
        </tr>
        <tr valign="top">
          <td><img height=1 src="/images/spacer.gif" width=1></td>
          <td><img height=1
             src="/images/box_btmline_left.gif" width=9 img></td>
          <td bgcolor="#660099"><img height=1 src="/images/spacer.gif" width=1></td>
          <td><img height=1
             src="/images/box_btmline_right.gif" width=9 img></td>
          <td><img height=1 src="/images/spacer.gif" width=1></td>
        </tr>
        </tbody>
      </table>
    </td>
  </tr>
</table>
<!-- do not edit or remove the script below -->
<script language="JavaScript1.1">
<!--
 generateMenus();
// -->
</script>
<!-- disclaimer table -->
</body>
</html>

 



__________________
~`^%
In Vino Veritas
Back to Top View shadowspell's Profile Search for other info by shadowspell
 
cwilliams
Admin Group
Admin Group
Avatar

Joined: April/26/2004
Location: United States
Online Status: Offline
Info: 137
Added: May/11/2004 at 4:27pm | IP Logged Quote cwilliams

Guess I cant help..
Like you said it's really too much code to look thru.



Edited by cwilliams on May/11/2004 at 4:55pm


__________________


Chris Williams
http://www.PowerASP.com
Back to Top View cwilliams's Profile Search for other info by cwilliams
 
shadowspell
Newbie
Newbie
Avatar

Joined: May/04/2004
Location: United States
Online Status: Offline
Info: 13
Added: May/11/2004 at 4:50pm | IP Logged Quote shadowspell

No problem dude!

 



__________________
~`^%
In Vino Veritas
Back to Top View shadowspell's Profile Search for other info by shadowspell
 
Hypa
Newbie
Newbie
Avatar

Joined: June/29/2004
Location: United States
Online Status: Offline
Info: 6
Added: July/01/2004 at 5:57pm | IP Logged Quote Hypa

Ok you have already done what I would have suggested first off.  Combining your tables into a single database.  you can always pull info out later if you want it seperate for one reason or another.  I have looked through your code.  Impressive and well written, but maybe im over analying this.  What exactly is your question?

"How can I capture the one description that goes with the name of the person being voted for?"

Do you mean with your radio button array?

 



__________________
Never Mess with a geek and his toys!
Back to Top View Hypa's Profile Search for other info by Hypa
 

Page of 2 Next >>
  A d d  -  P o s tAdd P o s t
Printable version Printable version

Info Jump
You cannot add new info in this area
You cannot add to info in this area
You cannot delete your info in this area
You cannot edit your info in this area
You cannot create polls in this area
You cannot vote in polls in this area

   Active Server Pages Rule The World
Contact Us  
All artwork, design & content contained in this site are Copyright © 1998 - 2025 PowerASP.com and Christopher J. Williams
Banner ads ,other site logos, etc are copyright of their respective companies.
STATS Unless otherwise noted - All Rights Reserved.

Active Server Pages ASP ASP.NET .aspx .ascx Web HTML Developer Internet Microsoft Web Services Visual Studio .NET CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspprotect.com, www.cjwsoft.com,www.aspclassifieds.com,www.aspphotogallery.com