The first thing you need to do is create a database called MyDatabase. Then create a table called tblLocations with these fields:
ID - autonumber
Location - text field
DateEntered - date/time field *** Also add "=Date()" as the default value for the field. This will add the date automatically, everytime a new record is entered. ***
Then, start adding a new record and enter "Miami : Take a left on Harris Street, right on Morgan Avenue, and we are the third building on the left". Enter some more records in the same fashion if you like.
Next, you create a page called displaypartoffield.asp and copy the below code into your page:
<% DIM mySQL, objRS mySQL = "SELECT * FROM tblLocations" Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open mySQL, objConn %>
<% DIM strLocation strLocation = Left(objRS("Location"), InStr(1, objRS("Location"), ":") - 1) Response.Write strLocation %> |
<% objRS.MoveNext Loop objRS.Close Set objRS = Nothing objConn.Close Set objConn = Nothing %> |
This script will return all of the records in your database and will display only the data to the left of the ":" in your Location field. If you want to display only the data to the right of the ":" , substitute the below code for the above.
<% DIM strLocation strLocation = Mid(objRS("Location"), InStr(1, objRS("Location"), ":") + 1) Response.Write strLocation %>
That's it, happy displaying!
http://www.aspwebpro.com/aspscripts/database/displaypartoffield.asp
No comments:
Post a Comment