473,480 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Record count in asp using vb.net

RAW
I am triyng to display the total of my records on my page using
RecordCounter as I used to in asp

thid sombody can give me an example
asp using vb.net
DIM mySqlStatment AS STRING = "SELECT * FROM properties WHERE Municipio = '"
& Replace(Municipio_Str, "'", "''") & "' AND '" & Replace(vr_Str,"'","''")
& "' OR '" & Replace(MLS_Int,"'", "''") & "'"

DIM objConnection AS NEW OledbConnection(strConnection)
DIM objCommand AS NEW oledbCommand(mySqlStatment, objConnection)
DIM objDataReader AS oledbDataReader

try
objConnection.open()
objDataReader = objCommand.ExecuteReader()

DO WHILE objDataReader.Read()= true

Response.write("Municipio")
Response.write("=")
Response.write(objDataReader("Municipio"))
Response.write("&")
Response.write("vr")
Response.write("=")
Response.write(objDataReader("vr"))
Response.write("&")

Nov 18 '05 #1
3 5506
A DataReader has exactly 1 record in it at any one time and therefore does
not support a RecordCount like classic ADO did.

You could do this though...

Dim i as Integer
Dim ReaderValue as String
Do While objDataReader.Read()
i += 1
ReaderValue = "Municipio=" & objDataReader("Municipio") & "&vr=" &
objDataReader("vr")
Loop

'At this point, i is equal to the amount of records in the DataReader
'and ReaderValue is equal to the name/value pairs in the reader

On a side note, in ASP.NET, you really don't need "Response.Write()"
statements anymore (allthough they still work). Just set up a Web Form
Label control and set its text property:

lblData.Text = ReaderValue

Scott M.
"RAW" <de****@terra.com> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
I am triyng to display the total of my records on my page using
RecordCounter as I used to in asp

thid sombody can give me an example
asp using vb.net
DIM mySqlStatment AS STRING = "SELECT * FROM properties WHERE Municipio = '" & Replace(Municipio_Str, "'", "''") & "' AND '" & Replace(vr_Str,"'","''") & "' OR '" & Replace(MLS_Int,"'", "''") & "'"

DIM objConnection AS NEW OledbConnection(strConnection)
DIM objCommand AS NEW oledbCommand(mySqlStatment, objConnection)
DIM objDataReader AS oledbDataReader

try
objConnection.open()
objDataReader = objCommand.ExecuteReader()

DO WHILE objDataReader.Read()= true

Response.write("Municipio")
Response.write("=")
Response.write(objDataReader("Municipio"))
Response.write("&")
Response.write("vr")
Response.write("=")
Response.write(objDataReader("vr"))
Response.write("&")

Nov 18 '05 #2
RAW
thanks for the tip

"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:On**************@tk2msftngp13.phx.gbl...
A DataReader has exactly 1 record in it at any one time and therefore does
not support a RecordCount like classic ADO did.

You could do this though...

Dim i as Integer
Dim ReaderValue as String
Do While objDataReader.Read()
i += 1
ReaderValue = "Municipio=" & objDataReader("Municipio") & "&vr=" &
objDataReader("vr")
Loop

'At this point, i is equal to the amount of records in the DataReader
'and ReaderValue is equal to the name/value pairs in the reader

On a side note, in ASP.NET, you really don't need "Response.Write()"
statements anymore (allthough they still work). Just set up a Web Form
Label control and set its text property:

lblData.Text = ReaderValue

Scott M.
"RAW" <de****@terra.com> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
I am triyng to display the total of my records on my page using
RecordCounter as I used to in asp

thid sombody can give me an example
asp using vb.net
DIM mySqlStatment AS STRING = "SELECT * FROM properties WHERE Municipio
= '"
& Replace(Municipio_Str, "'", "''") & "' AND '" &

Replace(vr_Str,"'","''")
& "' OR '" & Replace(MLS_Int,"'", "''") & "'"

DIM objConnection AS NEW OledbConnection(strConnection)
DIM objCommand AS NEW oledbCommand(mySqlStatment, objConnection)
DIM objDataReader AS oledbDataReader

try
objConnection.open()
objDataReader = objCommand.ExecuteReader()

DO WHILE objDataReader.Read()= true

Response.write("Municipio")
Response.write("=")
Response.write(objDataReader("Municipio"))
Response.write("&")
Response.write("vr")
Response.write("=")
Response.write(objDataReader("vr"))
Response.write("&")


Nov 18 '05 #3
Hi, the DataView object of ADO.net has a count property what will return the
number of rows in the DataSet. Overhead is more than just using loop like
Scott.M mentioned. You could always use SQL to do the count for you and then
query this via the datareader...

SELECT COUNT(EmployeeID) AS EmployeeNumber FROM Employees

Response.write("Number of employees is : " & oDR("EmployeeNumber"))

HTH
Cheers
mark

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1516
by: Daniel Ng | last post by:
Hi all, may i know how to write a simple code using asp to count the number of record in the Access and display the figure out... Thanks... *** Sent via Developersdex http://www.developersdex.com...
6
44076
by: Hari Om | last post by:
Here are the details of my error log files: I execute the command and get following message at console: ---------------------------------------------------------------------- ../sqlldr...
3
9262
by: thomasp | last post by:
I am trying to get a record count of a PHP query on a MS Acess database using ODBC with a DSN for MS ACCESS connection. I got this code from the PHP manual user notes. It seems to return the...
6
3053
by: 6thirty | last post by:
Hi, I've created a stocktaking database using Access XP. This is indexed by two fields - part number and shelf location. I am currently inputting all the data via a form. When I have entered a...
1
5387
by: Scott269 | last post by:
So I've got an old MS Works database I imported into Access. I needed a primary key so I created a record number field that was just the record number I manually inserted when I entered it in the...
1
3178
by: darrel | last post by:
I'm trying to whip up a fancy repeater control that will put records into a two-column table for me. This is how I envision it working: itemtemplate if record count = odd then write out the...
6
1991
by: Opie | last post by:
What would be a more efficient way for me to determine if a record in an SQL DB table exists? Right now, I have a try/catch like this: try {...
4
3072
by: Peter W Johnson | last post by:
Hi guys, I have a problem with a datagrid record count. Here is the code:- <snip> Public Class frmMerchantDeposit Inherits System.Windows.Forms.Form Dim myconnection As New...
2
3310
by: Catch_22 | last post by:
Hi, I have a stored procedure that has to extract the child records for particular parent records. The issue is that in some cases I do not want to extract all the child records only a...
3
1789
by: Ray | last post by:
Hello World, I made a Windowsform that reads data from a CSV file. It works fine, but when I have read the data of a record I have to re-Debug the form to read another record. So when I put a...
0
7041
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6739
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4779
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4481
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2995
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
181
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.