Displaying no of column in a database

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

Join Date: Dec 2007
Posts: 35
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
27 Days Ago
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
27 Days Ago
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: 35
Reputation: omotoyosi is an unknown quantity at this point 
Solved Threads: 1
omotoyosi omotoyosi is offline Offline
Light Poster
 
0
  #3
27 Days Ago
How will I attach the result to the label
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 16
Reputation: mIssy_ricco is an unknown quantity at this point 
Solved Threads: 1
mIssy_ricco mIssy_ricco is offline Offline
Newbie Poster
 
0
  #4
25 Days Ago
do u want to display the no or what?
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,612
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: 468
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven
 
0
  #5
25 Days Ago
You may use FieldCount property of DataReader or Count property of DataTable's columns collection.
Failure is not fatal, but failure to change might be. - John Wooden
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



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC