AboutSrini Nagarajan Expertise I can answer any kind of questions in ASP.NET, C#, VB.NET, SharePoint 2007, ASP, Coldfusion, Powerbuilder 7.00 / 8.00, JAVA servlets, MS SQL 2000 / MSSQL7, Sybase
Experience Contact me if you need any custom development on ASP.NET, ASP, SharePoint 2007, Coldfusion, Powerbuilder.
Expert: Srini Nagarajan Date: 9/25/2007 Subject: Asp Programming
Question how to disply information from database use asp
Answer Hi
Here is simple code to retrieve and display from database
html><head>
<TITLE>dbsimple.asp</TITLE>
</head>
<body bgcolor="#FFFFFF">
<%
' this code opens the database
myDSN="DSN=Student;uid=student;pwd=magic"
set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
' this code retrieves the data
mySQL="select * from publishers where state='NY'"
set rstemp=conntemp.execute(mySQL)
' this code detects if data is empty
If rstemp.eof then
response.write "No records matched<br>"
response.write mySQL & "<br>So cannot make table..."
connection.close
set connection=nothing
response.end
end if
%>
<table border=1>
<%
' This code puts fieldnames into column headings
response.write "<tr>"
for each whatever in rstemp.fields
response.write "<td><B>" & whatever.name & "</B></TD>"
next
response.write "</tr>"
' Now lets grab all the records
DO UNTIL rstemp.eof
' put fields into variables
pub_id=rstemp("pub_id")
pub_name=rstemp("pub_name")
city=rstemp("city")
state=rstemp("state")
country=rstemp("country")
' write the fields to browser
cellstart="<td align=""top"">"
response.write "<tr>"
response.write cellstart & pub_id & "</td>"
response.write cellstart & pub_name & "</td>"
response.write cellstart & city & "</td>"
response.write cellstart & state & "</td>"
response.write cellstart & country & "</td>"