count no of record
hello
i have two problems firstis i want to insert a value in table when submit at any post always 0 and second when any post is submitin another table then increament it by one there are two table topmaster and reply the column contain for count reply is noofreply i wants to when new post is posted insert 0 value in noofreply in topmaster and when reply posted in reply tabel on that topicid then increament it so please help me
my code for posting is:-(asp)
Set conn = Server.Createobject("ADODB.Connection")
conn.Open "DSN=ORACLE; User ID = STARTER; Password = STARTER"
Set R = Server.CreateObject("ADODB.Recordset")
R.Open "Select top_id from topmaster order by top_id", conn, adOpenStatic, adLockOptimistic, adCmdText
If R.Recordcount > 0 Then
R.Movelast
vtopid = R("top_id")
vtopid = CInt(vtopid) + 1
Else
vtopid = 1
End if
R.Close
R.Open "Select open_flg from topmaster ", conn, adOpenStatic, adLockOptimistic, adCmdText
if R.recordcount>0 then
R.movelast
vopenflg=R("open_flg")
vopenflg=1
end if
r.close
R.open "select no_of_reply from topmaster",conn, adOpenStatic, adLockOptimistic, adCmdText
if recordcount>0 then
R.movelast
vnoofreply=R("no_of_reply")
vnoofreply=0
end if
R.close
If Not IsEmpty(Request.Form("submit")) then
vtopstatus = Request.Form("vtopstatus")
vtopsub = Request.Form("vtopsub")
vopenflg=request.form("vopenflg")
vmsg = Request.Form("vmsg")
vtopsub = trim(vtopsub)
vopenflg=trim(vopenflg)
vnoofreply=trim(vnoofreply)
vmsg = trim(vmsg)
vtopstatus = trim(vtopstatus)
If len(errorMsg) = 0 Then
If len(vtopsub) = 0 Then
errorMsg = "Enter Topic Subject Plese"
End If
End if
If len(errorMsg) = 0 Then
If len(vmsg) = 0 Then
errorMsg = "Your must enter your voice"
Elseif len(vmsg) > 500 Then
errorMsg = "The voice you are entered is not longer than 500 characters. Please reduce the size."
End If
End If
If len(errorMsg) = 0 Then
conn.Close
conn.Mode = adModeReadWrite
conn.Open
R.Open "Select * from topmaster", conn, adOpenStatic, adLockOptimistic, adCmdText
R.Addnew
R("top_id") = vtopid
R("top_sub") = vtopsub
R("topic_status") = vtopstatus
R("launch_by") = request.cookies("userid")
R("launch_dt") = Cdate(date())
R("open_flg")= vopenflg
r("no_of_reply")=vnoofreply
R("msg") = vmsg
R.UPdate
R.Close
Response.Redirect "newtopic.asp"
End If
END IF
End If
code for increament if reply is post
code:(asp)
<%
R.Open "Select rep_id from reply order by rep_id", conn, adOpenStatic, adLockOptimistic, adCmdText
If R.Recordcount > 0 Then
R.Movelast
vrepid = R("rep_id")
vrepid = CInt(vrepid) + 1
Else
vrepid = 1
End if
R.Close
If Not IsEmpty(Request.Form("submit")) then
vtopid=request.form("vtopid")
vreply = Request.Form("vreply")
vtopid=trim(vtopid)
vrepid = trim(vrepid)
vreply = trim(vreply)
If len(errorMsg) = 0 Then
If len(vreply) = 0 Then
errorMsg = "Your must enter your Reply"
Elseif len(vreply) > 500 Then
errorMsg = "The voice you are entered is not longer than 500 characters. Please reduce the size."
End If
End If
If len(errorMsg) = 0 Then
conn.Close
conn.Mode = adModeReadWrite
conn.Open
R.Open "Select * from reply ", conn, adOpenStatic, adLockOptimistic, adCmdText
R.addnew
R("top_id") =vtopid
R("rep_id") = vrepid
R("rep_by") = request.cookies("userid")
R("rep_dt") = Cdate(date())
R("reply") = vreply
R.UPdate
R.Close
conn.close
conn.Mode = adModeReadWrite
conn.open
R.Open "Select no_of_reply from topmaster ", conn, adOpenStatic, adLockOptimistic, adCmdText
If isNull(vnoreply) or vnoreply = "" then
vnoreply = 1
else
vnoreply = vnoreply +1
End if
end if
R.Update
R.close
If len(errorMsg) > 0 Then
Response.Write "<p><b>" & errorMsg & "</b></p>"
end if
end if
%>
sanjeev
__________________
sanjeev
|