[thelist] Comments won't write to database...

Cathryn Bennett cbennett at foxdev.net
Mon Jul 15 13:51:13 CDT 2002


I'm reasonably new at this so bear with me.  All variables write to the
database except the comment field, it doesn't seem to want to pass through.
Can anyone give a quick look at my code and let me know what I'm doing
wrong?

Thanks...code follows....

<%
' Declare variables
Dim strURL     ' The URL of this page so the form will work
               ' no matter what this file is named.
Dim cnnSearch  ' ADO connection
Dim rstSearch  ' ADO recordset
Dim strSQL     ' The SQL Query we build on the fly
Dim strSearch  ' The text being looked for
Dim strUserName ' NT Authentication
Dim strIP       ' IP Address of the User
Dim strComments ' comments string

' Retreive the URL of this page from Server Variables
strURL = Request.ServerVariables("URL")

' Retreive the term being searched for.  I'm doing it on
' the QS since that allows people to bookmark results.
' You could just as easily have used the form collection.

strUserName = Request.ServerVariables("AUTH_USER")
strUserName = Right(strUserName, Len(strUserName)-InStrRev(strUserName,"\"))

strIP = Request.ServerVariables("LOCAL_ADDR")


Set CnnSearch = Server.CreateObject("ADODB.Connection")
CnnSearch.Open "dsn=employeeid"

'--Look up Employee information
strsql = "Select * From ID_PRO " &_
  "where Text_20_25 = '" & Replace(strUserName, "'", "''") & "' " &_
  "order by Text_3_25"

Set rstSearch = CnnSearch.Execute(strSQL)
%>

<%
If strUserName <> "" Then

 %>
<br>
      </blockquote>

<div align="center">
  <center>

<table cellpadding="4" cellspacing="0" width="50%">
 <tr>
          <td width="10%"><strong><u><font
size="2">Name</font></u></strong></td>
          <td width="4%"><strong><u><font
size="2">Initials</font></u></strong></td>
 </tr>
<%
 Do While not rstSearch.EOF
      xfirst = rstSearch.Fields("Text_1_25")
        xlast = rstSearch.fields("Text_3_25")
        xint = rstSearch.fields("Text_6_25")
%>
      <tr>
         <td width="75%"><font
size="2"><%=xfirst%>&nbsp;<%=xlast%></font></td>
         <td width="25%"><font size="2"><%=xint%></font></td>
  </tr>



<%

 rstSearch.MoveNext
 Loop

ELSE

'--Look up Employee information
strsql = "Select * From ID_PRO " &_
  "where Text_6_25 = '" & Replace(strSearch, "'", "''") & "' " &_
  "order by Text_3_25"

Set rstSearch = CnnSearch.Execute(strSQL)


%>
      <blockquote>
        <p align="left"><font color="#006699">
Please enter your SSS initials<br>
and click the FIND ME button:<br>

        </font>
<form action="<%= strURL %>" method="get">
<font color="#006699">
<input name="search" value="<%= strSearch %>" /><input type="submit"
value="Find Me">
</font>
</form>
%>
<%
End If
%>
 </table>

</center>
<br>
<br>
<br>

<form action="<%= strURL %>" method="get">
<font color="#006699">
<b>Comments:</b>  <input type=text name="Comments">

</font>
</form>

<%
strComments=Request.form("Comments")
%>

</center>

</div>

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

<a
href="http://000.00.0.000/take2/addsignin.asp?fint=<%=xint%>&amp;ffirst=<%=x
first%>&amp;flast=<%=xlast%>&amp;fcomment=<%=strComments%>&amp;fip=<%=strIP%
>"><img border="0"
src="file:///D:/My%20Documents/My%20Pictures/SSSence/signinbtnoff.gif"
width="170" height="24"></a>

<a
href="http://000.00.0.000/take2/addsignout.asp?fint=<%=xint%>&amp;ffirst=<%=
xfirst%>&amp;flast=<%=xlast%>&amp;fcomments=<%=strComments%>&amp;fip=<%=strI
P%>"><img border="0"
src="file:///D:/My%20Documents/My%20Pictures/SSSence/signoutbtnoff.gif"
width="170" height="24"></a>

NOTE:  the IP has been changed to 0's to protect the network <grin>

2nd page....

<%
FUNCTION DupQ (s)
'--This function turns single quotes into pairs of single quotes and
'--trims the input string.
 pos = InStr(s, "'")
 While pos > 0
  s = Mid(s, 1, pos) & "'" & Mid(s, pos + 1)
  pos = InStr(pos + 2, s, "'")
 Wend
   DupQ = Trim(s)
END FUNCTION
%>

<form action="<%= strURL %>" method="get">
<font color="#006699">
<b>Comments:</b>  <input type=text name="Comments">

</font>
</form>

<%
strComments=Request.form("Comments")
%>
<%
'--save data

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=signin"


 sql = "Insert into Timelog (" &_
  "Initials, First, Last, Comments, IPaddy, Signin) " &_
  "values (" &_
  "'" & DupQ(request.querystring ("fint")) & "', " &_
  "'" & DupQ(request.querystring ("ffirst")) & "', " &_
  "'" & DupQ(request.querystring ("flast")) & "',  " &_
  "'" & DupQ(request.querystring ("fcomments")) & "', " &_
  "'" & DupQ(request.querystring ("fip")) & "', " &_
  "1)"


Conn.execute(sql)

response.write("<p><b>Entry saved.</b></p>")


Conn.Close
Set Conn = nothing
%>

You have successfully signed in.  The Sign-In/Sign-Out
Log will appear in a moment.  If page does not refresh, <a
href="http://000.00.0.000/take2/timelog.htm">click here.</a>

Thanks again...

Cathryn




More information about the thelist mailing list