Recordcount in ASP.net
Recordcount in ASP.net
Recordcount in ASP.net
Recordcount in ASP.net
Recordcount in ASP.net
Recordcount in ASP.net Recordcount in ASP.net Recordcount in ASP.net Recordcount in ASP.net Recordcount in ASP.net Recordcount in ASP.net Recordcount in ASP.net Recordcount in ASP.net
Recordcount in ASP.net Recordcount in ASP.net
Recordcount in ASP.net
Go Back  Xtreme Visual Basic Talk > > > Recordcount in ASP.net


Reply
 
Thread Tools Display Modes
  #1  
Old 07-25-2007, 07:25 PM
3rick 3rick is offline
Newcomer
 
Join Date: Jul 2007
Posts: 2
Default Recordcount in ASP.net


Hi there, I'm just new in ASP.net and I'm trying to create a simple Login form with a typical Username/Password.

I've already connected to the database but I'm wondering why Can't I find any recordcount. Is there any alternative for this.

Here's my code. Please feel free to correct my mistakes.

Code:
Protected Sub cmdLogIn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdLogIn.Click

        Dim rsCom As OleDbCommand
        Dim strSql As String
        Dim user As String = txtUser.Text
        Dim pass As String = txtPass.Text


        If txtUser.Text = "" And txtPass.Text = "" Then
            lblMsg.Text = "Username and Password is required"
        ElseIf txtUser.Text = "" Or txtPass.Text = "" Then
            lblMsg.Text = "Incomplete data"
        Else

            lblMsg.Text = ""
            strSql = "Select * from Table1 where User='" & txtUser _
                     & "' pass='" & pass & "'"

            rsCom = New OleDbCommand(strSql, dbConn)
            rsCom.ExecuteNonQuery()

                if rscom.

            End If

    End Sub
Reply With Quote
  #2  
Old 07-25-2007, 08:27 PM
Eduardo Lorenzo's Avatar
Eduardo Lorenzo Eduardo Lorenzo is offline
Senior Contributor
 
Join Date: Jun 2006
Location: Manila, Philippines
Posts: 846
Default

Hi there 3rick and welcome to the forums! Do search and read our posting guidelines.

I cannot see from the code you posted where you would need a recordcount?
also, you are using ExecuteNonQuery() which is used for pushing/inserting data and not to read data.
__________________
Pinoy ako.. ipinagmamalaki ko.
Reply With Quote
  #3  
Old 07-25-2007, 10:52 PM
3rick 3rick is offline
Newcomer
 
Join Date: Jul 2007
Posts: 2
Default

Thanks for the reply ..... I've already found the solution. I have to use datasets. THanks again
Reply With Quote
  #4  
Old 07-28-2007, 09:39 AM
Azr@el's Avatar
Azr@el Azr@el is offline
Contributor
 
Join Date: Oct 2003
Location: Aachen, Germany
Posts: 407
Default

You don't.
There's also the ExecuteReader() method, which returns a data reader providing you easy access to the data.
__________________
Join #code @ irc://irc.RandomIRC.com
My JabberID: |Azrael|@jabber.ccc.de
Reply With Quote
  #5  
Old 07-28-2007, 09:45 AM
MKoslof's Avatar
MKoslofRecordcount in ASP.net MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

And there would be no performance gain in relation to getting the COUNT of records, that was the initial question. Yes you are absolutely correct that you can use a DataReader to navigate through data as long as its connection is alive, since its a live cursor on the data.

A DataSet, typically filled by a DataAdapter is a disconnected piece of data that lives beyond the scope of the connection which initially provided the data.

So, if he did a DataAdatper.Fill(ds) and then did a ds.Tables(0).Rows.Count for example, he would NOT be doing anything wrong. In fact, using a DataReader, looping each value and using some counter to increment total records would be just as fast or slower, so no real benefit, under *this* circumstance.

Now if the QUERY ITSELF was returning the record count, for example the query was "SELECT COUNT(Field) FROM dbo.T1" then the proper method to take would actually be .ExecuteScalar() which would return the object representation of that value, without the overhead of having the fill a DataSet or iterate via a cursor.

But this is under the circumstance where you have data and need to use that data for some purpose but also resolve a record count. Considering I believe this query should return ONE record either way (user login credentials), I'm not sure what the benefit would be in the first place, since the return is either 0 or 1
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown

Last edited by MKoslof; 07-28-2007 at 09:50 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Recordcount in ASP.net
Recordcount in ASP.net
Recordcount in ASP.net Recordcount in ASP.net
Recordcount in ASP.net
Recordcount in ASP.net
Recordcount in ASP.net Recordcount in ASP.net Recordcount in ASP.net Recordcount in ASP.net Recordcount in ASP.net Recordcount in ASP.net Recordcount in ASP.net
Recordcount in ASP.net
Recordcount in ASP.net
 
Recordcount in ASP.net
Recordcount in ASP.net
 
-->