473,382 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

getting rowcount


The below code doesn't give me the last record count.
Feedback very appreciated. Thanks for all that you do.

qstring = "SELECT COUNT(*) FROM CustomerInformation "

Dim newSql As New SqlConnection(connectionstr)
newSql.Open()
Dim catCMD As SqlCommand = newSql.CreateCommand()
catCMD.CommandText = qstring
Dim intRecordsAffected = catCMD.ExecuteNonQuery()
newSql.Close()
Jan 23 '08 #1
3 1181
Change the ExecuteNonQuery to ExecuteScalar and casting it to an Int32.
"segue" <se***@discussions.microsoft.comwrote in message
news:1D**********************************@microsof t.com...
>
The below code doesn't give me the last record count.
Feedback very appreciated. Thanks for all that you do.

qstring = "SELECT COUNT(*) FROM CustomerInformation "

Dim newSql As New SqlConnection(connectionstr)
newSql.Open()
Dim catCMD As SqlCommand = newSql.CreateCommand()
catCMD.CommandText = qstring
Dim intRecordsAffected = catCMD.ExecuteNonQuery()
newSql.Close()


Jan 23 '08 #2

Thanks for the quick response.

I made the ExecuteScalar change and still didn't get the highest number.
My query stopped at 114,278, row 114,279 is empty yet 114,300 isn't.

"Kelly Herald" wrote:
Change the ExecuteNonQuery to ExecuteScalar and casting it to an Int32.
"segue" <se***@discussions.microsoft.comwrote in message
news:1D**********************************@microsof t.com...

The below code doesn't give me the last record count.
Feedback very appreciated. Thanks for all that you do.

qstring = "SELECT COUNT(*) FROM CustomerInformation "

Dim newSql As New SqlConnection(connectionstr)
newSql.Open()
Dim catCMD As SqlCommand = newSql.CreateCommand()
catCMD.CommandText = qstring
Dim intRecordsAffected = catCMD.ExecuteNonQuery()
newSql.Close()


Jan 23 '08 #3
There is a big difference between count(*) which returns a count of the
number of rows in the table, and MAX(ID) which returns the highest value
present in the ID column.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"segue" wrote:
>
Thanks for the quick response.

I made the ExecuteScalar change and still didn't get the highest number.
My query stopped at 114,278, row 114,279 is empty yet 114,300 isn't.

"Kelly Herald" wrote:
Change the ExecuteNonQuery to ExecuteScalar and casting it to an Int32.
"segue" <se***@discussions.microsoft.comwrote in message
news:1D**********************************@microsof t.com...
>
The below code doesn't give me the last record count.
Feedback very appreciated. Thanks for all that you do.
>
qstring = "SELECT COUNT(*) FROM CustomerInformation "
>
Dim newSql As New SqlConnection(connectionstr)
newSql.Open()
Dim catCMD As SqlCommand = newSql.CreateCommand()
catCMD.CommandText = qstring
Dim intRecordsAffected = catCMD.ExecuteNonQuery()
newSql.Close()
>
>
Jan 23 '08 #4

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

Similar topics

5
by: wackyphill | last post by:
Is Set RowCount @RowCount More efficient than simply using TOP? Thanks for any input.
3
by: Dimitri Furman | last post by:
SQL Server 2000 SP3. Is it possible for the @@ROWCOUNT function to return NULL after a statement? I am troubleshooting a relatively large stored procedure with multiple SELECT statements and a...
4
by: Richard G | last post by:
I'm a database guy, so go easy on me here. :) How can I get the rowcount of the affected rows of a SQL statement from a stored procedure call? I know that "set nocount on" does not return the...
2
by: surekhads | last post by:
Hi all, I have developed a project for extracting data from a HTML file and export that data to a excel sheet. I am storing that extracted data to the db. And then I am exporting that data...
1
by: imranabdulaziz | last post by:
Dear All, I am using sql2005. i am writing stored procedure to save various master data . I recognize master by @type (input verible) and assign it to @mst veriable then based on @mst no I...
2
by: preeti13 | last post by:
i am tring to retrive the value form the data base but getting erorr i tried so many way but i didn't get the value i got the erorr like this: Implicit conversion from data type datetime to int is...
3
by: Andrus | last post by:
I have DataGridView in virtual mode containing 3500 rows. In code below, assigning to RowCount value to 3500 takes 8 seconds. CPU usage goes high at this time. Stepping by F11 into user code shows...
4
by: George Allen | last post by:
I have been experimenting wiht using the Listbox Callback function to solve an issue I have with my db tool. The function below connects ADO to a SQL server database and table and reads those...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.