Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

write all data and column names from database 1

Status
Not open for further replies.

tyutghf

Technical User
Apr 12, 2008
258
GB
I have a database but no SQL Manager so cannot see what the column names are or see what data is in those columns

How do I output using asp all column names and their data, I guess it is along the lines of

for each column in table
response.write columnname & ":" & column.value
next

the table is of the format

here1 here2 3here here4
there 1 2 3 4
there2 3 1 5 6
there3 2 3 2 1

so I would need to output

there

here1: 1
here2: 2
here3: 3
here4: 4

there2

here1: 3
here2: 1
here3: 5
here4: 6

is this possible?
 
Code:
sql = "select * from myTable"
set rs = conn.execute(sql)
rs.movefirst
do while not rs.eof
for each f in rs.fields
 response.write f.name & ":" & rs(f) & "<br />"
next
response.write "<hr />"
if not rs.eof then rs.movnext
loop
rs.close
set rs = nothing

--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
^ also, you can use MS Access as a front end tool to view the tables and make updates to the data by utilizing ODBC connections - if you don't know how to do this, let me know and I'll post a quick example.

You can use Access to update/export/import data into your sql server...

--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
I have tried the code but response.write statement doesn't work. what could be the problem
 
^
do you get an error?


--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
walkerdigest, the code posted had two slight errors, see if you can spot them.

Usually on this site I copy and paste an answer but then when I have more time go over them to learn what was happening. On this occasion I had to do the thought process first but noticed the errors very quickly, I am getting better at asp :eek:)
 
Here they are: (since I wrote the original code, I thought it might be nice to correct my mistakes):

Code:
response.write f.name & ":" & rs(f[COLOR=red].name[/color]) & "<br />"

Code:
if not rs.eof then rs.mov[COLOR=red]e[/color]next

Code:
sql = "select * from myTable"
set rs = conn.execute(sql)
rs.movefirst
do while not rs.eof
for each f in rs.fields
 response.write f.name & ":" & rs(f.name) & "<br />"
next
response.write "<hr />"
if not rs.eof then rs.movenext
loop
rs.close
set rs = nothing

:)

--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top