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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update problem

Status
Not open for further replies.

jordan11

Technical User
May 24, 2003
150
GB
I have done some calculations in my asp page and my problem is when it goes to update i get the error message
Object required

at this point in my code
txtsql = "DELETE FROM rating WHERE physicianID = '" _
& strphysicianid &"'"
conn.Execute txtsql


txtsql ="INSERT INTO rating (opportunityid,physicianID,rating)values ('" & StropportunityID & "','" & trim(request("physicianid")) &"', '" & rating & "')"

conn.Execute txtsql


set Conn = nothing

'rt.Close
'Set rt= nothing
oRScp.Movenext
Loop
oRScp.Close
Set oRScp= nothing
%>

I am not sure if i have my ,insert statement in the correct place but it has to be in the loop as i need it to update each opportunityid .
Also how can I put this into a function so I can call the function from other pages.
This is my total code



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Physician Career</title>
<!--#include file="connect.asp" -->
</head>
<body>


<%

set rx=server.createobject("ADODB.recordset")
txtsql= "select * from physiciancontact where physicianID ='" & REQUEST("id") & "'"
Set rx=conn.Execute(txtSQL)
strphysicianid=rx("physicianid")



'Session("physicianID") = Request("id")

Dim oRScp

set oRScp=server.createobject("ADODB.recordset")
txtSQL= "SELECT * FROM clientopportunity WHERE specialty = (SELECT physpecialty FROM physiciancontact where physicianID ='" & REQUEST("id") & "')"


Set oRScp=conn.Execute(txtSQL)
StrlocationState = oRScp("CLocationState")
strAMG = oRScp("AMG")
strsalarytype = oRScp("salarytype")
o_min = oRScp("salaryto")
o_max = oRScp("salaryfrom")


dim rt
set rt=server.createobject("ADODB.recordset")
txtsql="select o.questionID as oQuestionID,p.questionid as pquestionID "_
&"from opportunityanswers o inner join physiciananswers p "_
&"on o.questionID = p.questionID"_
&" and physicianID ='" & REQUEST("id") & "'"

Set rt=conn.Execute(txtSQL)

O_questionID = rt("oQuestionID")
P_questionID = rt("pquestionID")


dim rz
txtsql="select * from physicianqualifications where physicianID ='128'"

Set rz=conn.Execute(txtSQL)

medstate =rz("medstate")
paytype = rz("paytype")
p_min = rz("SalaryMinimum")
p_max = rz("SalaryExpected")


set rc=server.createobject("ADODB.recordset")
txtsql="select * from physicianpreference where physicianID ='128'"


Set rc=conn.Execute(txtSQL)
PreferedState= rc("PreferredState")



Errhandlerr Conn


%>

<form method="post" action="questions.asp">
<input type="hidden" name="PhysicianId" value="<%=request("ID")%>">
<%
Do while not oRScp.EOF
StropportunityID = oRScp("opportunityId")


geography=0
select case StrlocationState

CASE PreferredState
geography=geography+20
CASE medstate
geography=geography+50
CASE WHEN StateBirth
geography=geography+40

CASE ELSE
geography=geography+0

end select

geography=geography*30


qualifications=0
select case medstate
CASE "int"
qualifications=qualifications+(cint(clientopportunity)*10)
case ""
qualifications=qualifications
case Else
qualifications=qualifications+(cint(clientopportunity)*20)
end select

'select case??
'add another case select to add to qualificatioins

'end select
qualifications=qualifications*15




IF strsalarytype =1 then
o_min=cLng(o_min)*2080
else
o_max=CDbl(o_max)*2080
end if
IF paytype ="hourly" then
p_min=p_min*2080
else
p_max=CDbl(p_max)*2080
end if


salary=0
salcal=0
salcal=CDbl(p_min)-CDbl(o_max) * 100
if salcal < 10 then
salary=100
elseif salcal <=20 then
salary=80
elseif salcal <=21 and salcal <= 30 then
salary=60
elseif salcal > 40 then
salary=40
else salary=CDbl(salary)

end if


salary=CDbl(salary)*15


QUESTIONS=0
DO While not rt.EOF
O_questionID = rt("oQuestionID")
if isnull(O_questionID) then
question=question
else
question = cint(question) + 2
end if
rt.movenext
loop


QUESTIONS=QUESTIONS*15

rating=cint(QUESTIONS)+cint(salary)+cint(qualifications)

'RESPONSE.WRITE RATING
'RESPONSE.End
txtsql = "DELETE FROM rating WHERE physicianID = '" _
& strphysicianid &"'"
conn.Execute txtsql


txtsql ="INSERT INTO rating (opportunityid,physicianID,rating)values ('" & StropportunityID & "','" & trim(request("physicianid")) &"', '" & rating & "')"

conn.Execute txtsql


set Conn = nothing

'rt.Close
'Set rt= nothing
oRScp.Movenext
Loop
oRScp.Close
Set oRScp= nothing
%>

</form>

<%

Session("physicianID") = Request.Form("PhysicianID")

Response.Redirect "physicianpreference.asp?ID=" & trim(session("PhysicianID"))


%>

</body>
<!--#include file="disconnect.asp" -->
</html>



Thanks
 
you have used rz but i dont see you set rz to recordset object...

-DNG
 
i mean..put this line:

set rz=server.createobject("ADODB.recordset")

-DNG
 
Thanks
yes i did that but still get the error Object required
at (conn.Execute txtsql)

txtsql = "DELETE FROM rating WHERE physicianID = '" _
& strphysicianid &"'"
conn.Execute txtsql

and if i comment the above out i get the error at
txtsql ="INSERT INTO rating (opportunityid,physicianID,rating)values ('" & StropportunityID & "','" & trim(request("physicianid")) &"', '" & rating & "')"

conn.Execute txtsql
 
Where is your conn object buddy?? i dont see one

SET conn= Server.CreateObject("adodb.connection")

-DNG
 
My conn is in my include file but i found out the promlem i had set conn to nothing in the loop once i removed it worked.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top