473,395 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

dbase: how to get fieldNAME ofa table

Hello,

below you will find a simple script that reads out info of a dbase
It reads out all the records and every field of the record.
For my table header, I want to display the field names of the table

can ASP extract this information? How? What is the correct syntax?

tia

bartp
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open CONN_STRING
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL, Conn, adOpenStatic, adLockReadOnly, adCmdText
iRecords = RS.RecordCount
iFields = RS.Fields.Count
%>

<table border="1" align="center">
<TR bgcolor="#CCCCCC">
<%For j = 0 To iFields-1 %>
<TD><%response.Write("&nbsp;")%></TD> --------> this should be
modified to display the table header
<%Next 'j%>
</TR>
<%For i = 0 To iRecords-1 %>
<TR>
<%For j = 0 To iFields-1 %>
<TD><%response.Write(RS.Fields(j))%></TD>
<%Next 'j%>
</TR>
<%RS.MoveNext%>
<%Next 'i%>
</table>

<%
RS.Close
Set RS = Nothing
Conn.Close
Set Conn = Nothing
%>
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++

--

==========================================
Hyper A.R.T.
bart plessers
Paul Van Ostaijenlaan 4
3001 Heverlee
BELGIUM
tel: +32 (16) 23.40.85
fax: +32 (16) 23.41.06
==========================================


Jul 19 '05 #1
4 4022
I would say that typically you would want to manually control what is
displayed as the column headers, so instead of displaying something like
"fname," you can have "First Name." But, I see what you're trying to do.
This is how you can do it.

<%
Dim oADOX
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open CONN_STRING
Set oADOX = Server.CreateObject("ADOX.Catalog")
oADOX.ActiveConnection = Conn
For Each col in oADOX.Tables("YourTableName").Columns
Response.Write "<td>" & col.Name & "</td>"
Next
Set oADOX = Nothing
'''your other code


%>
Ray at home

"bart plessers" <ba**********@hotmail.com> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl...
Hello,

below you will find a simple script that reads out info of a dbase
It reads out all the records and every field of the record.
For my table header, I want to display the field names of the table

can ASP extract this information? How? What is the correct syntax?

tia

bartp
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open CONN_STRING
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL, Conn, adOpenStatic, adLockReadOnly, adCmdText
iRecords = RS.RecordCount
iFields = RS.Fields.Count
%>

<table border="1" align="center">
<TR bgcolor="#CCCCCC">
<%For j = 0 To iFields-1 %>
<TD><%response.Write("&nbsp;")%></TD> --------> this should be
modified to display the table header
<%Next 'j%>
</TR>
<%For i = 0 To iRecords-1 %>
<TR>
<%For j = 0 To iFields-1 %>
<TD><%response.Write(RS.Fields(j))%></TD>
<%Next 'j%>
</TR>
<%RS.MoveNext%>
<%Next 'i%>
</table>

<%
RS.Close
Set RS = Nothing
Conn.Close
Set Conn = Nothing
%>
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++

--

==========================================
Hyper A.R.T.
bart plessers
Paul Van Ostaijenlaan 4
3001 Heverlee
BELGIUM
tel: +32 (16) 23.40.85
fax: +32 (16) 23.41.06
==========================================


Jul 19 '05 #2
bart plessers wrote:
Hello,

below you will find a simple script that reads out info of a dbase
It reads out all the records and every field of the record.
For my table header, I want to display the field names of the table

can ASP extract this information? How? What is the correct syntax?

tia

bartp
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open CONN_STRING
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL, Conn, adOpenStatic, adLockReadOnly, adCmdText
iRecords = RS.RecordCount
iFields = RS.Fields.Count
%>

<table border="1" align="center">
<TR bgcolor="#CCCCCC">
<%For j = 0 To iFields-1 %>
<TD><%response.Write("&nbsp;")%></TD> --------> this should
be modified to display the table header
<%Next 'j%>
</TR>
<%For i = 0 To iRecords-1 %>
<TR>
<%For j = 0 To iFields-1 %>
<TD><%response.Write(RS.Fields(j))%></TD>
<%Next 'j%>
</TR>
<%RS.MoveNext%>
<%Next 'i%>
</table>

<%
RS.Close
Set RS = Nothing
Conn.Close
Set Conn = Nothing
%>


So you want the columns names ?
<%For j = 0 To iFields-1
Response.Write "<TD>" & RS.Fields(j).Name & "</TD>"
Next%>
Jul 19 '05 #3
Ray,

In fact, I was looking for the solution of jbongran (other post on here)

But the solution you gave me is very interesting also.

However, it seems that the order of columns in oADOX.Tables("YourTableName")
does NOT correspond to the order in the table. My columns are shifted 1 to
the right

Here is my table:
IdGallery
Name
sortorder
descend

with oADOX.Tables("YourTableName") I get
descend - idGallery - Name - Sortorder

with Response.Write "<TD>" & RS.Fields(j).Name & "</TD>", I get
idGallery - Name - Sortorder - descend
Any idea why this happens
thanx again
regards

--
HyperART
Paul Van Ostaijenlaan 4
3001 Heverlee

"Ray at <%=sLocation%>" <myfirstname at lane 34 . komm> wrote in message
news:e4*************@TK2MSFTNGP12.phx.gbl...
I would say that typically you would want to manually control what is
displayed as the column headers, so instead of displaying something like
"fname," you can have "First Name." But, I see what you're trying to do.
This is how you can do it.

<%
Dim oADOX
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open CONN_STRING
Set oADOX = Server.CreateObject("ADOX.Catalog")
oADOX.ActiveConnection = Conn
For Each col in oADOX.Tables("YourTableName").Columns
Response.Write "<td>" & col.Name & "</td>"
Next
Set oADOX = Nothing
'''your other code


%>
Ray at home

"bart plessers" <ba**********@hotmail.com> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl...
Hello,

below you will find a simple script that reads out info of a dbase
It reads out all the records and every field of the record.
For my table header, I want to display the field names of the table

can ASP extract this information? How? What is the correct syntax?

tia

bartp
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open CONN_STRING
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL, Conn, adOpenStatic, adLockReadOnly, adCmdText
iRecords = RS.RecordCount
iFields = RS.Fields.Count
%>

<table border="1" align="center">
<TR bgcolor="#CCCCCC">
<%For j = 0 To iFields-1 %>
<TD><%response.Write("&nbsp;")%></TD> --------> this should be
modified to display the table header
<%Next 'j%>
</TR>
<%For i = 0 To iRecords-1 %>
<TR>
<%For j = 0 To iFields-1 %>
<TD><%response.Write(RS.Fields(j))%></TD>
<%Next 'j%>
</TR>
<%RS.MoveNext%>
<%Next 'i%>
</table>

<%
RS.Close
Set RS = Nothing
Conn.Close
Set Conn = Nothing
%>
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++

--

==========================================
Hyper A.R.T.
bart plessers
Paul Van Ostaijenlaan 4
3001 Heverlee
BELGIUM
tel: +32 (16) 23.40.85
fax: +32 (16) 23.41.06
==========================================



Jul 19 '05 #4
Bart Plessers (artabel) wrote:
Ray,

In fact, I was looking for the solution of jbongran (other post on
here)

But the solution you gave me is very interesting also.

However, it seems that the order of columns in
oADOX.Tables("YourTableName") does NOT correspond to the order in the
table. My columns are shifted 1 to the right
Not exactly.

Here is my table:
IdGallery
Name
sortorder
descend

with oADOX.Tables("YourTableName") I get
descend - idGallery - Name - Sortorder

with Response.Write "<TD>" & RS.Fields(j).Name & "</TD>", I get
idGallery - Name - Sortorder - descend
Any idea why this happens

The column names are sorted alphabetically when retrieved from the schema.
There is another column that contains the ordinal position of the column
names being retrieved. Look it up in online help. If you don't have online
help on your pc, go to msdn/microsoft.com/library and use the tree menu on
the left to navigate to the appropriate documents in the Data node.

Bob Barrows
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Goldfisch1980 | last post by:
Hi! I read an dBase table under Win XP by the common dBase functions of PHP 4.3.5. But all records are displayd with a wrong charset. All umlauts of the databasefile like "öäüéô"... and so on...
10
by: level8 | last post by:
I would like to see a Clipper/dbase DBF file as a table in SQL Server 7.0. How can I SELECT rows from DBF file? Should I use OLE DB Provider or ODBC, and how?
5
by: Java script Dude | last post by:
For those who are missing the feature on how to import into Open Office dBase app from text files and spreadsheets in OOO Base 2.0: A wizard exists to import from spreadsheets only at this time...
1
by: Derek Griffiths | last post by:
Most of the complicated programs I write are boring applications that manipulate databases associated with the medical billing program where I work. The program uses foxpro dbases (version 3) for...
6
by: Tomek | last post by:
Hi, Please help me with Data Connections into dBase files. I have catalog with lot of files like *.dbf and *.mdx . Every file contains one table (I can see it in MS Access). How can I make...
6
by: coriolis_wong | last post by:
Hi, I need to transfer csv format file to DBase III format file. How do i do it in Python language? Any help is appreciated. Thanks.
3
by: Dave | last post by:
I'm writing a c# Windows program that needs to be able to insert records into a dbase table. I can read it using a dataset but can't insert records. I receive the following error, ERROR ...
6
by: Aleyna[] | last post by:
Hi all, I wanted to connect an old DBASE file (I don't know the exact version) but I could not make it at all. I couldn't find a way to execute sql statements on db file using c#. The...
10
by: Johny | last post by:
Is there a module for reading/modifing db files from Python? Thanks for help B.
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.