retrieve a value from a table and display it on screen

Hi There,

I am newbie to ASP. How can I retrieve a value from a table and display it on my screen?

<iframe width="100%" height="300">
  <p>// display the value here.</p>
</iframe>

Thanks.
thearthaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pateljituCommented:
Please refer to these links for further details on how to fetch data from database table and display on page, as not sure on your preference on coding have provided with both classic ASP and .NET version example, hope this help.

Classic ASP:
http://www.w3schools.com/ado/ado_examples.asp

ASP.NET:
http://www.w3schools.com/aspnet/aspnet_examples.asp
http://www.w3schools.com/aspnet/aspnet_dbconnection.asp

Good Luck
worthyking1CTOCommented:
There are a ton of ways to do this, depending on your database type and personal preferences. here's a simple way to do it with a SQL Server database.

The below, of course, is pretty generic because I have no idea what your DB table looks like or how many rows you're fetching etc. You'll need to customize the SQL connection string to match your situation as well as your SQL query. But hopefully this will give you a good starting point.

<%
' SQL Conneciton string
ThisSQL_Conn = "Driver={SQL Server};Server=(local);Database=YourDBName;uid=YourDBUser;pwd=YourDBPswd"

'Site db connection
Set Con = Server.CreateObject("Adodb.Connection")
Con.Open ThisSQL_Conn

' Open recordset
Set rs = Con.Execute("SELECT Field1,Field2 FROM TableName WHERE Field1 = 'value'")

' Populate vars
MyField1 = rs("Field1")
MyField2 = rs("Field2")

' Display values
%>
<iframe width="100%" height="300">
  <p><%=MyField1%> - <%=MyField2%></p>
</iframe>

Open in new window


Not sure why you're using an iFrame either, but I just put that in there as that is what you showed in your example.

For connection strings on other servers or DBs you can always check: http://www.connectionstrings.com/

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.