Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 2nd, 2007, 04:12 AM
Authorized User
 
Join Date: Nov 2007
Location: patna, bihar, India.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sanjeev jha
Default Record count and increament it with one

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><h2>POST YOUR REPLY</h2></b></center>

<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><b>Topic ID</b></center></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>" & errorMsg & "</b></p>"
end if
end if
%>



sanjeev
__________________
sanjeev
  #2 (permalink)  
Old November 4th, 2007, 11:19 PM
Authorized User
 
Join Date: Nov 2007
Location: patna, bihar, India.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sanjeev jha
Default

Hi
i am using this code for count reply and i found my results. thanks to all reader.

     R.Open "Select max(no_of_reply) as mnoreply from topmaster where top_id="&vtopid&"", conn, adOpenStatic, adLockOptimistic, adCmdText
      vnoreply=R("mnoreply")
      vnoreply = cint(vnoreply)+1
      vnoreply=vnoreply
      R.close
      R.Open "Select no_of_reply from topmaster where top_id="&vtopid&"", conn, adOpenStatic, adLockOptimistic, adCmdText
      R("no_of_reply")=vnoreply
      R.Update
      R.close

sanjeev


Similar Threads
Thread Thread Starter Forum Replies Last Post
count no of record sanjeev jha ADO.NET 1 November 5th, 2007 12:28 PM
Record count deb1980 ASP.NET 2.0 Basics 6 April 10th, 2007 12:42 PM
Count Record prasanta2expert Access 3 November 28th, 2006 10:42 AM
How to count a record when it is not there Mitch Access 1 October 3rd, 2003 03:49 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.