Home > SQL Development > How to get the field's name from a table ?

How to get the field's name from a table ?



<i><b>Originally posted by : Gal Tamir - Israel (gtamir@applicom.co.il)</b></i><br /><br />I have a very small problem ( I think so ).<br />I want to get a list of all the fields from a specific table.<br /><br />Can someone help me with that one ???<br /><br />Thanks,<br /><br />Gal.<br /><br />More info:<br />Let's say I have table named "DBUser"<br />and in that table there are 3 fields : "DBName" "DBFamily" "DBAddress".<br />How can I get these field names if I don't know them already ?<br /><br /><br />

    
Guest


<i><b>Originally posted by : padmaja tallavajhala (coolpersona@hotmail.com)</b></i><br /><% <br /> 'establish connection to the database to open recordset<br /> '--------------------------------------------------------------------------------<br /> stDataPath = Server.mappath("accessdata esttravel raveldata.mdb")<br /> sSQL = "Select * from tbl_arrangements;" <br /> <br /> Set oConn = Server.CreateObject("ADODB.Connection")<br /> Set oRs = Server.CreateObject("ADODB.Recordset")<br /> oConn.Open "DBQ=" & stDataPath & ";Driver={Microsoft Access Driver (*.mdb)};" <br /> oRs.Open sSQL, oConn, 1, 3<br /> <br /> 'start moving through the records of the database<br /> '---------------------------------------------------------------------------------<br /> oRs.MoveFirst <br /><br />%><br /> <TABLE BORDER=1 COLS=<% = oRS.Fields.Count%>> <br /> <TR><br /> <% For Each oField In oRS.Fields %><br /> <TH> <% = oField.Name %> </TH><br /> <% Next %><br /> </TR><br /> <% Do While Not oRS.EOF %><br /> <TR><br /> <% For Each oField In oRS.Fields %><br /> <TD ALIGN=RIGHT><br /> <% If IsNull(oField) Then <br /> Response.Write " "<br /> Else<br /> Response.Write oField.Value<br /> End If %><br /> </TD> <br /> <% Next <br /> oRS.MoveNext %><br /> </TR><br /> <% Loop %><br /> </TABLE><br /><% oRs.Close<br /> Set oRs = Nothing %><br /><br />Hope this clarifies your doubt...<br /><br />------------<br />Gal Tamir - Israel at 6/13/2000 9:56:54 AM<br /><br /><br />I have a very small problem ( I think so ).<br />I want to get a list of all the fields from a specific table.<br /><br />Can someone help me with that one ???<br /><br />Thanks,<br /><br />Gal.<br /><br />More info:<br />Let's say I have table named "DBUser"<br />and in that table there are 3 fields : "DBName" "DBFamily" "DBAddress".<br />How can I get these field names if I don't know them already ?<br /><br /><br />

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved