|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
VBScript - Database - General - I could not link the selected records
<%
Dim con,rs,sl set con=server.CreateObject("ADODB.Connection") set rs=server.CreateObject("ADODB.Recordset") con.open Application("db") sl = "SELECT * FROM projects " rs.Open sl,con Do While Not rs.EOF Response.Write rs("Tittle") & " " & "<br>" rs.MoveNext Loop rs.Close con.Close%> hi the above code is used to select the titles from a table projects ..what im unable to do is ..i have to display the records in a td and i have to use a marquee tool.when i click ever single name a text file stored with that project name should get opened ..can anyone help me for that ..i need it urgently ..explain me the path that should be given to..thank u |
|
#2
|
|||
|
|||
|
Quote:
I guess div and css. Initially the text is hidden then when you click the item the relevant div is displayed and other divs get hidden. |
|
#3
|
|||
|
|||
|
Quote:
..jonathan i wana know hw to set the link inside the while loop thats the problem.my text file are saved in E:/jp/textfiles/.txt hw to set the link for that can u help me |
|
#4
|
||||
|
||||
|
If I understand you correctly you can do something like this, in the example I am assuming that the fielname is held in a field called file_name:
Code:
<%
Dim con,rs,sl
set con=server.CreateObject("ADODB.Connection")
set rs=server.CreateObject("ADODB.Recordset")
con.open Application("db")
sl = "SELECT * FROM projects "
rs.Open sl,con
Do While Not rs.EOF
Response.Write("<a href=""E:\jp\textfiles\" & rs.Fields("file_name") & ".txt"" target=""_blank"">" & rs("Tittle") & "</a>")
rs.MoveNext
Loop
rs.Close
con.Close
%>
|
|
#5
|
|||
|
|||
|
Quote:
hi swim u did understand my requirement now im able to set the link but when i click that the text files does open ..i have stored my text files in E:\jp\textfiles.were i have stored four text files ..help me with that. |
|
#6
|
|||
|
|||
|
Quote:
if i use urs the error says either BOF OR EOF should be true or the current record is deleted but i have records in that field |
|
#7
|
||||
|
||||
|
Hi,
I think you will have to approach this slightly differently, have the link take the user to a new page and use the filesystemobject to display the contents of the textfile. First, change the link so that it passes the name of the file as a querystring: Code:
<%
Dim con,rs,sl
set con=server.CreateObject("ADODB.Connection")
set rs=server.CreateObject("ADODB.Recordset")
con.open Application("db")
sl = "SELECT * FROM projects "
rs.Open sl,con
Do While Not rs.EOF
Response.Write("<a href=""displayfile.asp?whichfile=" & rs.Fields("file_name") & ".txt"" target=""_blank"">" & rs("Tittle") & "</a>")
rs.MoveNext
Loop
rs.Close
con.Close
%>
This link will open displayfile.asp in a new window, add the following code to displayfile.asp: Code:
'Not Tested!!
set fso = createobject("scripting.filesystemobject")
Dim u_file
u_file = "E:\jp\textfiles\" & Request.Querystring("whichfile")
if fso.FileExists (u_file) then
' Open the file and read it
set act = fso.opentextfile(u_file)
read_text = act.readall
act.close
' Write the contents of the document ot the browser
Response.Write "<pre>" & server.htmlencode(read_text) & "</pre>"
' If the file in the querystring does not exist
' Display and eror message
else
%>
There was a problem displaying the requested item<br>
Please go <a href=<%= request.servervariables("script_name")%>>back</a> and select again<%
' End check for file existence
end if
%>
|
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > VBScript - Database - General - I could not link the selected records |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|