|
 |
asp_web_howto thread: Controlling entries trouble
Message #1 by "kostas lagos" <nkia@i...> on Tue, 3 Dec 2002 10:16:09
|
|
Hello everybody,
I have a problem that tortures me for the last 3 days!!
I have 2 forms in one page(tabControl.asp) and the proccessing code in
another (tabControlProccess.asp). The data are being stored in a database
(Oracle).In the form page you have 2 choices:Add a record in a database
table or delete one..This is ok so far..
If you try to insert a record with two specific fields matching (Foreign
and master key), an error is generated (i have placed a unique index)..In
this case i have put in my code an 'on Error Resume Next' and an 'if
Error.Number<>0 Then..' which updates the record.Everything till here
works just fine but when i try to display a message through Response.Write
statements when this Error occurs, my INSERT Statement also displays this
message! I have tried to transfer contrl to another page but i lose the
data that i want to update (even with server.transfer)..
I give the code(for the very very patient ones) below from the trouble
page:
On Error Resume Next
Dim getSelected, getYearsOfExperience, tmpSelected, noAdd, recaff
Dim getGainedKnowledge, getMoreInvolvment, getUsedRecently,
getDoUpdate
Dim getTab, getSetOfBtns, GetSelection, objComm2, objComm3
Dim sqlStr2,sqlStr3
getDoUpdate=Request.QueryString("doUpdate")
getSelection=Request("selectionDisplay")
getSelected=Request("choicesFromSelected")
getYearsOfExperience=Request("yearsOfExperience")
getGainedKnowledge=Request("gainedKnowledge")
getMoreInvolvment=Request("moreInvolvmentDesired")
getUsedRecently=Request("whenUsedRecently")
getTab=Request.QUERYSTRING("tab")
getSetOfBtns=Request.QUERYSTRING("setOfButtons")
If (getMoreInvolvment="0" or getYearsOfExperience="0" _
or getGainedKnowledge="0" or getusedRecently="0" _
or getSelected="") and getSelection="" and Request.QueryString
("doAdd") and Not(Request.QueryString("doDelete")) Then
Response.Redirect("tabControl1.asp?noAdd=True&tab=" & getTab
& "&setOfButtons=" & int(getsetofbtns))
Elseif (getMoreInvolvment<>"0" and getUsedRecently<>"0" _
or getYearsOfExperience<>"0" and getGainedKnowledge<>"0") _
and getSelection="" and getSelected<>"" and
Request.QueryString("doAdd") Then
sqlStr2="INSERT INTO quest_data VALUES(" &Session("TmpKod_ypal")
& ",'" & _
getSelected& "'," &getYearsOfExperience& "," &getUsedRecently& ","
& _
getMoreInvolvment& "," &getGainedKnowledge& ",'" &Date& "')"
Set objComm2=Server.CreateObject("ADODB.Command")
objComm2.ActiveConnection=maindb
objComm2.CommandText=sqlStr2
objComm2.Execute recaff
If Error.Number<>0 and recaff="" Then
sqlStr2="UPDATE quest_data SET YEAR_EXP=" & getYearsOfExperience &
_
",USED_REC=" & getUsedRecently & ",GAIN_KNOW="&
getGainedKnowledge & _
",MORE_INV=" & getMoreInvolvment & ",UPD_DATE='"
&Date& "'" & _
" WHERE KOD_YPAL=" & Session("TmpKod_ypal") & " AND
KNOWLEDGE='" & getSelected & "'"
Set objComm2=Server.CreateObject("ADODB.Command")
objComm2.ActiveConnection=maindb
objComm2.CommandText=sqlStr2
objComm2.Execute
Response.Redirect("tabControl1.asp?noAdd=False&tab=" & getTab
& "&setOfButtons=" & int(getsetofbtns))
End If
Response.Redirect("tabControl1.asp?noAdd=False&tab=" & getTab
& "&setOfButtons=" & int(getSetOfBtns))
End If
If Not(getSelection="") Then
sqlStr3="DELETE FROM quest_data WHERE KOD_YPAL=" &Session
("TmpKod_ypal")& " AND KNOWLEDGE LIKE '" &getSelection& "'"
Set objComm3=Server.CreateObject("ADODB.Command")
objComm3.ActiveConnection=maindb
objComm3.CommandText=sqlStr3
objComm3.Execute
Response.Redirect("tabControl1.asp?noAdd=False&tab=" &
getTab & "&setOfButtons=" & int(getSetOfBtns))
ElseIf (getSelection="" and Not(Request.QueryString("doAdd")))
Then
Response.Redirect("tabControl1.asp?noAdd=False&tab=" &
getTab & "&setOfButtons=" & int(getSetOfBtns))
End If
%>
Thanks for your time
Lagos Kostas
|
|
 |