RE: help with a form (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


BeTheBall -> RE: help with a form (6/28/2004 12:33:09)

Post the most current versions of both files and I will team them up with the copy of the db you sent me. That will be later today as the db is on my site at home.




jaberwocky -> RE: help with a form (6/28/2004 12:38:56)

thanks...much appreciated. I am still going to look at it and try to figure out whats wrong. Here is the Form page:
<%@ Language=VBScript %>
<% Response.Buffer=true %>
<%	
dim conn
 Session.timeout = 2

Set conn = Server.CreateObject("ADODB.Connection")
    conn.open "attendance2004","",""
    	sQl="SELECT * FROM ""servicesStaffQuery"" ORDER BY ""shiftcode"" ASC, ""fullname"" ASC"
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open sql, conn, 3, 3
%>
<html>

<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=windows-1252">
<title>Services Scheduled Shifts</title>
</head>

<body bgcolor="" text="navy">

<form METHOD="POST" ACTION="shifts2.asp" style="border: 1px solid #000000; background-color: #EAEAEA; ">
<p align="left"><font color="#00008B">Week Starting: <input type="text" name="weekof" size="20"> mm/dd/yyyy
</font></p>
<table WIDTH="220" BORDER="0" CELLSPACING="0">
  <font FACE="Arial" COLOR="#000000">

<tr>
    <th BGCOLOR="#ffffcc" WIDTH="140" align="left" ><span style="font-weight: 400"><font FACE="Arial" COLOR="darkblue">Name</font></span></th>
    <th BGCOLOR="#ffffcc" WIDTH="100" align="right"><span style="font-weight: 400"><font FACE="Arial" COLOR="darkblue"># Shifts Sched</font></span></th>
</tr>
</table>
<span id="dataPanel" 
style="font:10pt;height:420px;width=400px;visibility:visible;overflow:scroll;background:#ffffff;border:0 
inset black"> 

<table WIDTH="324" BORDER="0" CELLSPACING="0">
  <font FACE="Arial" COLOR="#000000">
<%
i=0
On Error Resume Next
rs.MoveFirst
Do While Not RS.EOF
i=i+1
%>

<tr>
    <td WIDTH="120"><font SIZE="2"><input type="HIDDEN" name="fullname<%=i%>" value="<%Response.Write(rs.Fields("FullName"))%>"><%Response.Write(rs.Fields("FullName"))%></font></td>
    <td width="58" align="center"><font color="blue"><input TYPE="text" NAME="shiftsworked<%=i%>" size="5">
  </tr>

<%
rs.MoveNext
loop%></span>
      <td><input type="submit" value="Submit" name="submit"></left></td>
<input type = "HIDDEN" Name = "recCount" Value = <%=i%>> 

</table>
</form>
</font>
</body>
</html>


and the update page
<% DIM conntemp, mySQL, myDSN, recCount

recCount=Request.Form("recCount")
myDSN = "DSN=attendance2004" 
set conntemp=server.createobject("adodb.connection") 
conntemp.open myDSN 

FOR i = 1 to recCount

IF Request("ShiftsWorked" & i) <> "" THEN 

mySQL = "INSERT INTO ShiftsWorkedCOPY (WeekOf, FullName, ShiftsWorked) VALUES"
mySQL = mySQL & " (#" & Request("WeekOf") & "#, '" & Request("Fullname" & i) & "', " & Request("ShiftsWorked" & i) & ")"
conntemp.execute(mySQL) 
END IF 

NEXT 
conntemp.close 
set conntemp=nothing 
Response.write "Records added."
%>




BeTheBall -> RE: help with a form (6/28/2004 20:52:35)

Worked for me. The only issue I had was that in the db you sent me, there was no field titled "shiftcode" in the query named "servicesStaffQuery", however, that immediately threw an error.




jaberwocky -> RE: help with a form (6/28/2004 21:01:29)

hmmm ok then. The 'ShiftCode' was added later, after i sent you the database, and it does exist in my query now.

hmm OK, i am going to have to take a second look and see why my data isnt entering the databse when i do it here.. i just tried it again to make sure




jaberwocky -> RE: help with a form (6/28/2004 21:22:28)

OK... it works now!! I dont know why... i didnt touch the code, nuthin.. just tried it again. Maybe it didnt like the dates i was choosing... dunno.. go figure.

but it seems OK LOL [8|]




BeTheBall -> RE: help with a form (6/28/2004 21:44:53)

It does seem a little tempermental. Keep an eye on it.

Spooky, if you are following this thread, do you know of any reason why an update statement would be intermitent in that sometimes the update works and others not, but when it doesn't it throws no error message?




Spooky -> RE: help with a form (6/28/2004 22:46:11)

Im not a fan of DSN's - it is better for many reasons to use a DSN'less connection via OLEDB
That could be part of the problem




Page: <<   < prev  1 [2]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.0625