 |
| ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.1 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
|
|
|
|

November 30th, 2004, 01:14 PM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Retrieve number of rows from table
In my page, I use ExecuteNonQuery to access database. But I am having problem in retrieving number of rows from database table.
Any suggestion?
|
|

November 30th, 2004, 01:53 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
What are you exectuing, a queyr, stored procedure ..? You would have to return the number of rows back from the query or SP.
|
|

November 30th, 2004, 02:26 PM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
What I am trying to do is that I want to add new row of data to my database table. If I have typed the data, I want to compare the data typed, with the primary key field in database table. If the data key in by myself is already exist in database, then perform rollback, and vice-versa.
For myself, I just guess that if I would want to compare the data, then I have to loop through all the column/field value for the particular database table. Before I can do so, I guess further that I have to know how many rows there are in the database table, so that there will have no out-of-bound problem when I use for loop to compare the primary key field.
I have referred to few books, but I can't get the solution. So, I have to try and test it myself. Please correct me if what I guess is wrong. :)
|
|

November 30th, 2004, 03:01 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Is your data key a primary key?
|
|

November 30th, 2004, 03:13 PM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ya, my data key is primary key.
My time here is 3:09am. Will be back at the next day. Thanks for the reply. ;)
|
|

November 30th, 2004, 04:18 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Since it is a primary key the database will reject duplicates and not 'commit' the INSERT. I would recommend letting the database handle the primary key by setting it to AutoNumber. That way each INSERT will get a new primary key and you won't have to worry about anything but INSERTing the proper info.
|
|

December 1st, 2004, 03:25 PM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
If I use the auto number for primary key, the problem here is that, in sql server, can the auto number be the combination of character and integer number, for example, MYCAR001, N01, and the like.
Another problem is that, if I use auto generated primary key, how I know until which number the primary key is generated in database table? Or do you mean I can always retrieve the latest primary key from database to my textbox each time I load the front end application?
|
|

December 1st, 2004, 04:21 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Access will handle the autonumber and it usually starts with 1 and increments by 1 unless you change it to start higher and increment by a different value.
You can always SELECT MAX(auto_number_column) to get the latest record. (I have read that Access will autonumber with negative numbers without you specifing it but have never seen it nor do I know what version they were referring to.)
|
|
 |