|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Grab the Database Column Names??
im reading from multiple databases, and one restraint is that i must know the amount of columns and the names of the columns before i can display info from the database.
my question: can i somehow GRAB or READ this information from each database and then just adapt my Display accordingly??? thanks
__________________
"Morgoth i Cried All Hope is Gone But i Swear REVENGE Hear my Oath!!" |
|
#2
|
||||
|
||||
|
I'm not shure what database you are using. If you're using Microsoft SQL server, you can use the sysobject table to get the table names, syscolumns gives you the columns in the table, and systypes the (I guess this is obvious) types. The following query can be used to get all the tables, columns and types (If you use a count, you should be able to find the number of columns as well).
I don't know if other databases also store their tables, columns etc. in seperate tables. They probably do, so you can search for tables with names that look funny Code:
select a.name, b.name, c.name from sysobjects a left join syscolumns b on (b.id = a.id) left join systypes c on (c.xtype = b.xtype) where a.xtype = 'u' order by a.id, b.colorder |
|
#3
|
|||
|
|||
|
ok, thanks, i know nothing about 'sys'objects.. but ill check it out...thanks alot.
|
|
#4
|
|||
|
|||
|
hmm... im working with ms access.. doe sthe query work with access??
|
|
#5
|
||||
|
||||
|
here's a sample. HTH.
Code:
' objRecordset is the result object of your database query for each Fields in objRecordset.Fields response.write (Fields.Name & " : " & Fields.Value) next number of fields/columns can be taken from : objRecordset.Fields.Count |
|
#6
|
|||
|
|||
|
GREAT!!!!! Works like a charm!!! thanks alot man!!! now only the databas ename also.... but that cant be to hard right?
![]() thanks |
|
#7
|
||||
|
||||
|
roninblade - This is brilliant. I should have thought of it myself
Thanks |
|
#8
|
||||
|
||||
|
no problem guys. im only starting out with asp myself.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Grab the Database Column Names?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|