• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

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.
0
theartha
Asked:
theartha
1 Solution
 
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
0
 
worthyking1Commented:
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/
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now