Displaying no of column in a database

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Dec 2007
Posts: 38
Reputation: omotoyosi is an unknown quantity at this point 
Solved Threads: 1
omotoyosi omotoyosi is offline Offline
Light Poster

Displaying no of column in a database

 
0
  #1
Nov 3rd, 2009
please, I want a sql query that will return the no of fields in a database as an integer

example
i have table student
columns are
regno
surname
othername


I want my result to be 3

what do i do??
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 34
Reputation: vizy is an unknown quantity at this point 
Solved Threads: 6
vizy's Avatar
vizy vizy is offline Offline
Light Poster
 
0
  #2
Nov 3rd, 2009
Hi

Try the query like this

  1. SELECT count(*)
  2. FROM INFORMATION_SCHEMA.COLUMNS
  3. WHERE TABLE_NAME = 'mytable'
Njoy koding... >>>
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 38
Reputation: omotoyosi is an unknown quantity at this point 
Solved Threads: 1
omotoyosi omotoyosi is offline Offline
Light Poster
 
0
  #3
Nov 3rd, 2009
How will I attach the result to the label
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 21
Reputation: mIssy_ricco is an unknown quantity at this point 
Solved Threads: 1
mIssy_ricco mIssy_ricco is offline Offline
Newbie Poster
 
0
  #4
Nov 5th, 2009
do u want to display the no or what?
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,721
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 500
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven
 
0
  #5
Nov 5th, 2009
You may use FieldCount property of DataReader or Count property of DataTable's columns collection.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC