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??

Recommended Answers

All 4 Replies

Hi

Try the query like this

SELECT count(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'mytable'

How will I attach the result to the label

do u want to display the no or what?

You may use FieldCount property of DataReader or Count property of DataTable's columns collection.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.