- Home
·
- Active Server Pages
·
- Get All fields and values from a database by entering the name of table. Written in ASP.
Get All fields and values from a database by entering the name of table. Written in ASP.
Get All fields and values from a database by entering the name of table. Written in ASP.
Rate Get All fields and values from a database by entering the name of table. Written in ASP.
(3(3 Vote))
<!--this code is combination of asp and html to reduse the usage of resoponse.write-->
<html>
<body>
<form action=viewtable.asp method=get/post>
Table Name:<input type=text name=t1>
<input type=submit value="show recod">
</form>
<hr>
table=TRIM(request("t1"))
if table<> " " then
'connect with database
set rs=server.creataobject("Adodb.recordset")
set cn=server.creataobject("Adodb.connection")
cn.open "dsn=dsnName;uid=admin;pwd=;"
'u can also use dsnless connection
'data base connected
%>
<table border=1>
<tr>
<% for i=0 to rs.field.count-1%>
<th><%=rs(i).name%></th>
<!--this woud pickup the fields form the database)-->
<%next%>
<%while not RS.EOF%>
<tr>
<%for i=0 to rs.field.count-1%>
<td><%=rs(i).value%></td>
<%next%>
</tr>
<%rs.movenext%>
<%wend%>
</table>
<%end if%>
</body></html>
<!--<%the code is between these sign will be asp code%>
save this fiel with the name viewtable.asp
first it run the html code that is the texbox and button,
then it get vlaue from the text box and chekc the condition
if textbox <> "" then connect u with the data base.
it is necessary to understand the name u enter the textbox
must be the name of table in the data base.
we use the for loop to pick the fields and vlaue for database.
to get all values form data base we use while loop.
For more information or any difficulty in asp(just for guidness)
contact me
[email protected]
Get All fields and values from a database by entering the name of table. Written in ASP. Comments
No comments yet — be the first to post one!
Post a Comment