Newsgroup: it.comp.www.asp
Titolo: Avere i metadata di una tabella

Ciao a tutti
volevo chiedere se con le pagine asp è possibile fare una cosa del genere
fare uan query su di una tabella per poter poi stampare indipendentemente
tutti i nomi e i valori delle colonne della tabella stessa: ad esempio:
select * from tabella
while (!ris.EOF)
response.write(prima colonna) +  response.write(valore_prima colonna);
.......
Grazie anticipatamente
PIERO GIACOMELLI 
pgiac...@netics.com
 Junior Analist Tech Dept. NETICS
S.p.A. NETICS MEDIA Inc. Via S. Agnese, 2/b Redwood City 36016 Thiene,
(VI) - ITALY California 94065 - USA tel: 
+39.0445.381133
 - fax:
+39.0445.360011
 tel: 
+1.650.632.4415
 - fax: 
+1.650.551.9901
 URL:
www.netics.com
 URL: 
www.neticsmedia.com
 e-mail: 
in...@netics.com
 e-mail:
in...@neticsmedia.com

 Grazie anticipatamente
Prova con questo script. Fa un pň di piů di quello che ti serve ma č sempre
molto utile
Ciao
<Antonio>
      <%
 mydsn = request.form("mydsn")
 mytable = request.form("mytable")
 dobuild = request.form("dobuild")
%>
Costruisci SQL
      <form method="post" action="sql.asp">
        <table>
          <tr>
            <td class="grassetto" align="right">DSN/Connection String</td>
            <td>
              <input type="text" name="mydsn" maxlength="300" size="70"
value="<%=mydsn%>" class="base">
            </td>
          </tr>
          <tr>
            <td class="grassetto" align="right">Esempio Dsn:<br>
              Esempio Connection String:</td>
            <td class="base">DSN=arena;uid=myusr;pwd=654321<br>
              Driver={SQL
Server};Server=120.30.23.230;Database=databasename;Uid=aUser;Pwd=aPwd;</td>
          </tr>
          <tr>
            <td class="grassetto" align="right">Nome della tabella</td>
            <td>
              <input type="text" name="mytable" size="55" maxlength="300"
value="<%=mytable%>" class="base">
            </td>
          </tr>
          <tr>
            <td align="right" class="grassetto">Esempio:</td>
            <td class="base">anagrafe</td>
          </tr>
          <tr>
            <td colspan="2">
              <input type="submit" name="Submit" value="Invia" class="base">
              <input type="hidden" name="dobuild" value="1">
            </td>
          </tr>
        </table>
      </form>
<%
if dobuild = 1 then
set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
tablename = mytable
mySQL="select * from " & tablename
set rstemp=conntemp.execute(mySQL)
%>
<%
response.write "<b>TABELLA " & mytable & "</b><br>"
mycounter = 0
for each whatever in rstemp.fields
 myquerystring = myquerystring & 
whatever.name
 & " =
trim(replace(request.querystring(" & chr(34) & 
whatever.name
 & chr(34) &
")," & chr(34) & "'" & chr(34) & "," & chr(34) & "''" & chr(34) & "))<br>"
 myform = myform & 
whatever.name
 & " = trim(replace(request.form(" & chr(34)
& 
whatever.name
 & chr(34) & ")," & chr(34) & "'" & chr(34) & "," & chr(34) &
"''" & chr(34) & "))<br>"
 select case whatever.Type
' HOW TO HANDLE INTEGERS
 case "20", "11", "14", "5", "64", "3", "131","4", "2", "21", "19", "18",
"17"
 isthetype = "INT"
 if mycounter = 0 then
  myinsertstatement = "INSERT INTO " & tablename & " (" & 
whatever.name
  myinsertstatement2 = "values (" & chr(34) & chr(38) & 
whatever.name
 &
chr(38) & chr(34) & ""
  myupdatestatement = "UPDATE " & tablename & " SET " & 
whatever.name
 & " =
" & chr(34) & chr(38) & 
whatever.name
 & chr(38) & chr(34) & ""
  mydeletestatement = "DELETE FROM " & tablename & " WHERE CONDITION"
 else
   myinsertstatement = myinsertstatement & ", " & 
whatever.name
  myinsertstatement2 = myinsertstatement2 & ", " & chr(34) & chr(38) &
whatever.name
 & chr(38) & chr(34) & ""
  myupdatestatement = myupdatestatement & ", " & 
whatever.name
 & " = " &
chr(34) & chr(38) & 
whatever.name
 & chr(38) & chr(34) & ""
 end if
 mycounter = mycounter + 1
'HOW TO HANDLE STRINGS
 case "133", "134", "135", "130", "202", "12", "200", "138", "201", "203",
"205"
 isthetype = "STRING"
 if mycounter = 0 then
  myinsertstatement = "INSERT INTO " & tablename & " (" & 
whatever.name
  myinsertstatement2 = "values ('" & chr(34) & chr(38) & 
whatever.name
 &
chr(38) & chr(34) & "'"
  myupdatestatement = "UPDATE " & tablename & " SET " & 
whatever.name
 & " =
'" & chr(34) & chr(38) & 
whatever.name
 & chr(38) & chr(34) & "'"
  mydeletestatement = "DELETE FROM " & tablename & " WHERE CONDITION"
 else
   myinsertstatement = myinsertstatement & ", " & 
whatever.name
  myinsertstatement2 = myinsertstatement2 & ", '" & chr(34) & chr(38) &
whatever.name
 & chr(38) & chr(34) & "'"
  myupdatestatement = myupdatestatement & ", " & 
whatever.name
 & " = '" &
chr(34) & chr(38) & 
whatever.name
 & chr(38) & chr(34) & "'"
 end if
 mycounter = mycounter + 1
 end select
response.write "" & 
whatever.name
 & " - " & whatever.DefinedSize & " - " &
isthetype & "<br>"
next
  myinsertstatement = myinsertstatement & ")"
  myinsertstatement2 = myinsertstatement2 & ")"
  myupdatestatement = myupdatestatement & chr(34) & " WHERE CONDITION"
  response.write "<br><b>REQUEST QUERYSTRING</b><br>"
  response.write myquerystring & "<br><br>"
  response.write "<b>REQUEST FORM</b><br>"
  response.write myform & "<br><br>"
  response.write "<b>INSERT STATEMENT</b><br>"
  response.write myinsertstatement & " " & myinsertstatement2 &
"<br><br><br>"
  response.write "<b>UPDATE STATEMENT</b><br>"
  response.write myupdatestatement  & "<br><br>"
  response.write "<b>DELETE STATEMENT</b><br>"
  response.write mydeletestatement
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
end if
%>