Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help me debug, please

Status
Not open for further replies.

janise

Technical User
May 25, 2003
161
US
I am trying to create two records at the same time.
What I mean is, I need to give the hr department an opportunity to determine when an accident occurs, who is at fault.
So I created a screen that allows the hr dept to enter records about the employee involved in an accident and to also enter info about the police that responded to the accident.
The employee part is work but the police is not.
Please take a look and see if you can help me.
thanks in advance.
<%@ Language=VBScript%>
<%Response.buffer=true%>

<html>
<head>
<title>Untitled</title>
</head>

<body>

<%
Set connectionToDatabase=Server.CreateObject(&quot;ADODB.Connection&quot;)
Set recordSet=Server.CreateObject(&quot;ADODB.Recordset&quot;)
connectionToDatabase.Open &quot;DSN=aTrac;UID=janis;PWD=pass&quot;


recordSet.Open &quot;SELECT * FROM Driver&quot;,connectionToDatabase,1,3

Dim ss_nbr, fname, validate
validate=true

for each qryItem in Request.Form
if Request.Form(qryItem) = &quot;&quot; Then
validate = false
Response.Write(&quot;Missing : &quot; & qryItem & &quot;<BR>&quot;)
End if
next

if not validate then
Response.Write(&quot;<body bgcolor=steelblue><BR><font color=red><h3><b>&quot; &_
&quot;Please click the back button and complete the missing fields. &quot; &_
&quot;Thank You</b></h3></font></body> &quot;)
else

recordSet.AddNew
'recordSet(&quot;date&quot;) = date()
'recordSet(&quot;time&quot;) = Time()

recordSet(&quot;DriverID&quot;) = Request.Form(&quot;SS_NUM&quot;)
recordSet(&quot;lname&quot;) = Request.Form(&quot;LAST_NAME&quot;)
recordSet(&quot;fname&quot;) = Request.Form(&quot;FIRST_NAME&quot;)
recordSet(&quot;MI&quot;) = Request.Form(&quot;Middle_Initial&quot;)
recordSet(&quot;DriverGender&quot;) = Request.Form(&quot;Driver_Sex&quot;)
recordSet(&quot;Address1&quot;) = Request.Form(&quot;Address1&quot;)
recordSet(&quot;Address2&quot;) = Request.Form(&quot;Address2&quot;)
recordSet(&quot;CityAdd&quot;) = Request.Form(&quot;City&quot;)
recordSet(&quot;StateAdd&quot;) = Request.Form(&quot;STATE&quot;)
recordSet(&quot;ZipAdd&quot;) = Request.Form(&quot;ZIP_CODE&quot;)
recordSet(&quot;PhoneHome&quot;) = Request.Form(&quot;Home_Phone&quot;)
recordSet(&quot;PhoneWork&quot;) = Request.Form(&quot;Work_Phone&quot;)
recordSet(&quot;EmailAdd&quot;) = Request.Form(&quot;Email_Address&quot;)
recordSet(&quot;Result&quot;) = Request.Form(&quot;reason&quot;)
recordSet(&quot;InfluenceType&quot;) = Request.Form(&quot;Influence_Type&quot;)
recordSet(&quot;InjuryType&quot;) = Request.Form(&quot;Injury_Type&quot;)
recordSet.Update





recordSet.Open &quot;SELECT * FROM Police&quot;,connectionToDatabase,1,3




recordSet.AddNew
'recordSet(&quot;date&quot;) = date()
'recordSet(&quot;time&quot;) = Time()

recordSet(&quot;PoliceID&quot;) = Request.Form(&quot;code&quot;)
recordSet(&quot;offFname&quot;) = Request.Form(&quot;offfname&quot;)
recordSet(&quot;offLname&quot;) = Request.Form(&quot;offlname&quot;)
recordSet(&quot;accidentType&quot;) = Request.Form(&quot;accident&quot;)
recordSet(&quot;accidentReport&quot;) = Request.Form(&quot;remarks&quot;)

recordSet.Update





connectionToDatabase.Close
Set connectionToDatabase=Nothing

if Request.Form(&quot;CoApp&quot;) = &quot;NO&quot; Then
Response.Redirect &quot;co_applicant.asp?ss_nbr=&quot; & Request.Form(&quot;SS_NUM&quot;)
else
Response.Redirect &quot;new_applicant.asp&quot;
end if
end if
end if
%>


</body>
</html>
 
you're opening the DB for read-only mode
recordSet.Open &quot;SELECT * FROM Driver&quot;,connectionToDatabase,1,3
to
recordSet.Open &quot;SELECT * FROM Driver&quot;,connectionToDatabase,3,3

admin@onpntwebdesigns.com
 
add this in the appropriate spots
Set recordSet=Server.CreateObject(&quot;ADODB.Recordset&quot;)
Set recordSet2=Server.CreateObject(&quot;ADODB.Recordset&quot;)

recordSet2.Open &quot;SELECT * FROM Police&quot;,connectionToDatabase,3,3

recordSet.Close
recordSet2.Close
Set recordSet Nothing
Set recordSet2 = Nothing

admin@onpntwebdesigns.com
 
thanks onpnt!
for some reason,it is still not inserting into the police table.
 
try closing the first RS after the first add before you open the RS2. If that does not work try the normal debug system of response.writing the SQl and form values for assurance everything looks normal
admin@onpntwebdesigns.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top