Forums
This topic is locked
Record count and increament it with one
Posted 02 Nov 2007 11:56:49
1
has voted
02 Nov 2007 11:56:49 sanjeev jha posted:
i am using two table for post topmaster and for reply reply table one field is in topmaster for increament of reply is reply is post so i can't able to increase or insert any value in that fild i wants to when any body post new then insert auto value=0 if reply is post then add 1 and increament so on
i am using code for new post
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
%>
and using code for post reply
<%
Dim R,r1, stropt1,detail1,vnoreply, sql,vcount
Dim vrepby,vtopid,vrepid,vrepdt,vreply,errorMsg,conn,i
Set conn = Server.Createobject("ADODB.Connection"
conn.Open "DSN=ORACLE; User ID = STARTER; Password = STARTER"
Set R = Server.CreateObject("ADODB.Recordset"
Set R1 = Server.CreateObject("ADODB.Recordset"
R1.Open "Select top_sub from topmaster ", conn, adOpenStatic, adLockOptimistic, adCmdText
%><br>
<center><b><font face="arial"><h2>POST YOUR REPLY</h2></font></b></center>
<hr>
<p>
<div style="Position:Absolute; top:90; left:200; width:760;background-color:skyblue">
<table border=0 width=500 >
<%
For Each stropt1 in Request.QueryString
%>
<tr><td width="15%" align="center"><th><font face="monotype corsiva"><b>Topic ID</b></center></font></th></td><%Response.Write "<td >" & Request.QueryString(stropt1) & "</td></tr>"%>
<%vtopid=request.querystring(stropt1)
detail1=request.querystring(stropt1)
vcount=request.querystring(stropt1)%>
<tr><td></td><td align="center" width="15%"><b>Topic Sub</b></td><td width="80%" align="left"><%=R1("top_sub"%></td></tr>
</tr>
<%next %>
</table>
</div>
<%
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><font color='red'>" & errorMsg & "</font></b></p>"
end if
end if
%>
jha