VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Get All fields and values from a database by entering the name of table. Written in ASP.

by Kashif Nisar (4 Submissions)
Category: Active Server Pages
Compatability: ASP (Active Server Pages)
Difficulty: Unknown Difficulty
Originally Published: Tue 22nd October 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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.



<!--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]


Download this snippet    Add to My Saved Code

Get All fields and values from a database by entering the name of table. Written in ASP. Comments

No comments have been posted about Get All fields and values from a database by entering the name of table. Written in ASP.. Why not be the first to post a comment about Get All fields and values from a database by entering the name of table. Written in ASP..

Post your comment

Subject:
Message:
0/1000 characters