I'm trying to teach myself ASP while building a work order system for our school. Just about got it done and have learned that making sure you get valid data from the user is "somewhat" important So I've borrowed and adapted this script from a book. The following is the data entry file for the user. The script is intended to insure that each field is filled out and properly in the case of the date. If not, it is supposed to return the user to the page with the focus on the proper field and display a dialog box. It almost works. When I push submit with blank data, I get the warning box. However, when I push ok on it, I get sent to my ASP page with this error message:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver]Error in row
/workorder/WorkOrder_Info.asp, line 89
The relevant section of code from WorkOrder_Info.asp is as follows (line 89 is the oRS.Update):
My data entry form code is as follows:
The program works great as long as the data is valid. I appreciate any help anyone can give.
Thanks
Rick
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver]Error in row
/workorder/WorkOrder_Info.asp, line 89
The relevant section of code from WorkOrder_Info.asp is as follows (line 89 is the oRS.Update):
Code:
Set oConn=Server.CreateObject("ADODB.Connection")
oConn.Open "DSN=WorkOrder"
Set oRS=Server.CreateObject("ADODB.Recordset")
'******************************************
'Execute this code If New work order Is submitted
'******************************************
If Request.Form("Action")="Add" Then
'********************************************
'Select Recordset
'********************************************
sqltext="Select * FROM results"
oRS.Open sqltext, oConn,adOpenkeyset,adLockOptimistic
'***************************************************
'Print out the recordset (In place for debug only)
'***************************************************
'Do While Not oRS.EOF
' Response.Write oRS("ID") &" "& oRS("Name") &"<br>"
' oRS.MoveNext
'Loop
'****************************************************
ORS.AddNew
oRS("Name")=Request.Form("Name")
oRS("submitDate")=Request.Form("submitDate")
oRS("Priority")=Request.Form("Priority")
oRS("Campus")=Request.Form("Campus")
oRS("Building")=Request.Form("Building")
oRS("Room")=Request.Form("Room")
oRS("WorkRequested")=Request.Form("WorkRequested")
oRS.Update
My data entry form code is as follows:
Code:
<html>
<head>
<title>FISD Maintenance Work Order Request Form</title>
<link rel="stylesheet" href="WorkOrder.css" type="text/css">
<Script Language=vbscript>
Sub WOSubmit_OnClick()
If Len(WorkOrderAdd.Name.value)=0 Then
Alert "Please enter your name."
WorkOrderAdd.Name.focus
Exit Sub
ElseIf Len(WorkOrderAdd.submitDate.value)=0 Then
Alert "Please enter the Date."
WorkOrderAdd.submitDate.focus
Exit Sub
ElseIf NOT IsDate(WorkOrderAdd.submitDate.value) Then
Alert "Please enter Date as mm/dd/yy"
WorkOrderAdd.submitDate.focus
Exit Sub
ElseIf Len(WorkOrderAdd.Building.value)=0 Then
Alert "Please enter the Building (number or description)."
WorkOrderAdd.Building.focus
Exit Sub
ElseIf Len(WorkOrderAdd.Room.value)=0 Then
Alert "Please enter the Room."
WorkOrderAdd.Room.focus
Exit Sub
ElseIf Len(WorkOrderAdd.WorkRequested.value)=0 Then
Alert "Seems sort of silly to submit a work order and not tell us what needs fixing, Doesn't it?"
WorkOrderAdd.WorkRequested.focus
Exit Sub
End if
Call WorkOrderAdd.submit()
End Sub
</Script>
</head>
<body style="text-align: center">
<h1 class="wo" align="center">Work Order Request Form</h1>
<form method="POST" action="WorkOrder_Info.asp" Name="WorkOrderAdd">
<input Type="hidden" name="Action" value="Add">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="33%">Name:<br>
<input type="text" name="Name" size="20"></td>
<td width="33%">Date:<br>
<input type="text" name="submitDate" size="20"></td>
<td width="34%">Priority:<br>
<select size="1" name="Priority">
<option selected value="3-Repair">Repair</option>
<option value="1-Life/Safety">Life/Safety</option>
<option value="2-Emergency">Emergency</option>
<option value="4-Prevention">Prevention</option>
<option value="5-Improvement">Improvement</option>
</select></td>
</tr>
<tr>
<td width="33%">Campus:<br>
<select size="1" name="Campus">
<option selected>FHS</option>
<option>FMS</option>
<option>FES</option>
<option>FPS</option>
<option>Stonewall</option>
<option>Special Ed</option>
<option>AEP</option>
<option>GCLC</option>
<option>Central Office</option>
<option>Transportation </option>
</select></td>
<td width="33%">Building:<br>
<input type="text" name="Building" size="20"></td>
<td width="34%">Room:<br>
<input type="text" name="Room" size="14"></td>
</tr>
<tr>
<td width="100%" colspan="3">
<p align="center">Work Requested:<br>
<textarea rows="4" name="WorkRequested" cols="44"></textarea></td>
</tr>
</table>
<p><input type="submit" value="Enter this Work Order" name="WOSubmit"><input type="Button" value="Reset this information" name="WOReset"></p>
<!----><Input type="button" value="Edit Existing Work Order" onClick=window.location="[URL unfurl="true"]http://intra/workorder/edit.htm">[/URL]
</form>
</body>
</html>
The program works great as long as the data is valid. I appreciate any help anyone can give.
Thanks
Rick