Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Write a HTML-link from a database ?


Message #1 by "Vandael Tim" <vandael_tim@h...> on Thu, 28 Mar 2002 12:50:58
Hello,

my problem is that i wanne be able to write a html-link from a database.
in my field Shortcut, i fill in the name of the file, ex. text.txt

i use this code to generate my page,

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<titleMembers</title>
	
<!-- Neem ADO-naamconstanten op -->
<!-- #include file="adovbs.inc" -->
<%
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Open de verbinding met db3.mdb
''''''''''''''''''''''''''''''''''''''''
Set cnn1 = Server.CreateObject("ADODB.Connection")
openStr = "driver={Microsoft Access Driver (*.mdb)};" & _
          "dbq=" & Server.MapPath("db3.mdb")
cnn1.Open openStr,"",""
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' Create Recordset objects
Set objRS = Server.CreateObject("ADODB.Recordset")

Set objComm = Server.CreateObject("ADODB.Command")
objComm.ActiveConnection = openStr
objComm.CommandText = "qry_material"       ' Access query
objComm.CommandType = adCmdStoredProc

Set objRS = objComm.Execute
' execute the query
Set objParam = Nothing
Set objComm = Nothing

Do Until objRS.EOF         ' do something with recordset

%>

</head>

<body>
<!-- De heading voor een HTML-tabel -->
<table border="1" cellspacing="0" cellpadding="3">
	<caption><b>Materials</b></caption>
<%
Response.Write "<tr>" & vbCrLf

For i = 0 To objRS.Fields.Count-1
	Response.Write "  <th>" & _
		Server.HTMLEncode(objRS.Fields(i).Name) & _
		"</th>" & vbCrLf	
Next

Response.Write "<tr>" & vbCrLf

Do While Not objRS.EOF
	Response.Write "<tr>" & vbCrLf
	For i = 0 To objRS.Fields.Count-1
		Response.Write "  <td>" & _
			Server.HTMLEncode(objRS.Fields(i)) & _
			"</td>" & vbCrLf
	Next
	
	Response.Write "</tr>" & vbCrLf
	objRS.MoveNext
Loop
Loop
%>
</table>
</body>
</html>

My output is just the way i want it, but there is one thing that is not 
good.

My output of the field Description is "machine1.txt" and the Output of 
Machine is "Saw"

and it has to be a hyperlink, that the output is 

<a href="c:\files\machine1.txt" TARGET="_blank">Saw</a>

Is this possible ?

thnx

Tim








  Return to Index