Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 2nd, 2007, 02:21 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 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
Reply With Quote
  #2 (permalink)  
Old November 5th, 2007, 12:28 PM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Dear sanjeev jha:
1_ I didnt get ur problem, sorry.
2_ its ADO.NET not asp
but anyway I'll do my best if u explain it a bit clearly:)

Always:),
Hovik Melkomian.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
record count help jpaul VB Databases Basics 2 January 22nd, 2008 02:49 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



All times are GMT -4. The time now is 11:59 PM.


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