Wrox Programmer Forums
|
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
 
Old February 17th, 2007, 04:56 AM
Registered User
 
Join Date: Feb 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default the right one

I have a problem with VB Recordset.recordcount property
it always return (-1) here is my code:

Private Sub del_cmd_Click()
    If IDText.Text = "" Then
        MsgBox "Enter the ID number first ..."
    Else
        Sql = "select count(*) from Activ where ACTIV_ID = " & Text1.Text
        CN.Execute Sql
    End If
    MsgBox rs.RecordCount
    If rs.RecordCount = 0 Then
       MsgBox "The ID number is not found ..."
    Else
        n = MsgBox("Are you sure you want to delete record? ", vbOKCancel)
        If n = 1 Then
        Sql = "delete from Activ where ACTIV_ID = " & IDText.Text
            CN.Execute Sql
            MsgBox "Record deleted..."
       End If
    End If
End Sub

 
Old February 18th, 2007, 12:39 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You never open the recordset object, you just use cn.execute, your recordset will always return -1 in this case.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429
 
Old February 18th, 2007, 06:13 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You may want to take a look here: http://www.adopenstatic.com/faq/recordcounterror.asp to understand why the recordset returns -1

BTW, is this really ASP? All those MsgBox statements make it look more like VB / VBA or a VBS script....

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.









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