By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,600 Members | 1,666 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,600 IT Pros & Developers. It's quick & easy.

How to count records in database

Kosal
P: 68
Dear All

Can you help me to do as below

I need to count record in database using VB.net 2005 in the table(id, product, quentity, unitprice, sName) and form interface had one textbox when i input supplier name into textbox and click button count it show number of supplier,

please help to give me the code for this.

thanks
Jul 23 '08 #1
Share this Question
Share on Google+
7 Replies


DrBunchman
Expert 100+
P: 979
Hi Kosal,

You don't say which database you use but you can use the COUNT function.

In SQL Server for example the syntax is:
Expand|Select|Wrap|Line Numbers
  1.  SELECT COUNT(*) FROM Table WHERE id = 123
Hope this helps,

Dr B
Jul 23 '08 #2

10K+
P: 13,264
When the button is clicked just do a select count(*) for the suppliers.
It does not have to (and should not) be linked with the entering of suppliers themselves.

Edit: Too late ...
Jul 23 '08 #3

Kosal
P: 68
ok thanks

but i need to count supplier name not count id
Jul 23 '08 #4

DrBunchman
Expert 100+
P: 979
You can count whatever you like.
Expand|Select|Wrap|Line Numbers
  1. SELECT COUNT(*) WHERE .....
will return a count of all the records whose conditions satisfy your WHERE clause.

Dr B
Jul 23 '08 #5

10K+
P: 13,264
ok thanks

but i need to count supplier name not count id
Suppose there are only two suppliers in the table and they both have the same name, then should it show one or two?
Jul 23 '08 #6

Kosal
P: 68
Hello sir
now it is ok
thank you for your help
Jul 23 '08 #7

P: 2
select count(sname) from table;
Jul 23 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.