I am trying to connnect to a database in Ms Access through ASP. I have one field in Access for hyperlinks. this field is of type hyperlink. But, when I run the page,it does not show hyperlink as a link..it just shows it as a text. How to resolve that?
as a basis sampathsl is correct Can you post a URL for us to see? maybe by viewing the source code we might be more helpful
I was able to get the links now. But they are coming with a # sign before and after the link..like #www.site.com# How to resolve this? I don't have # sign in my database. I am picking up links form a "hyperlink" field in MS Access.
it might be a solution to put all the information in a regular field or change the properties for column from hyperlink to text.
I cannot do that..because there is a limit of 255 characters for that field. My links are going to be longer.
Can you please check your code..it dosen't works. I am getting result with <a href= "<%=(ltrim(rs.Fields.Item("link").Value))%>"><%=(ltrim(rs.Fields.Item("link").Value))%></a> but it gives # sign. anyone plz help.
Put the URL's into a longtext type field in the database and try something like this <a href="<%=rs("URL")%>"><%=rs("URLTEXT")%></a>
Thanks. memo field does works. I have another problem - I want to delete few records from the databse through SQL and then display the rest of them? how to do that? is there any way to do it in one query or will I have to write seperate queries? If Ihave to write seperate quesries, then do I have to create a new connection string for it? Can you please give me a sample code?
You can delete it directly from a RecordSet e.g: 'Move to record(s) you want to delete objRS.Delete() objRS.Update() objRS.MoveFirst() Do While Not objRS.EOF 'Display the updated recordset here Loop Code (markup):
But it would be easier to do two different queries. I use this code to do all of my database queries (using MS Access database) this might be useful to you, you would just have to change the connection string in the exSQL function: Structure dbconnect Dim objConn As Object Dim objRS As Object Sub Close() objConn.Close() objConn = Nothing objRS = Nothing End Sub End Structure Function exSQL(ByVal sql As String) As dbconnect exSQL.objConn = CreateObject("ADODB.Connection") exSQL.objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Datasource.mdb;" exSQL.objConn.Open() exSQL.objRS = CreateObject("ADODB.Recordset") exSQL.objRS.CursorType = 2 exSQL.objRS.LockType = 3 exSQL.objRS.Open(sql, exSQL.objConn) End Function Code (markup): an example usage would be: Dim dbc As dbconnect dbc = exSQL("SELECT * FROM Users WHERE username = '" & usr & "'") dbc.objRS.Delete() dbc.objRS.Update() dbc.Close() dbc = exSQL("SELECT * FROM Users") Do While Not dbc.objRS.EOF Response.Write("Username: " & dbc.objRS("username").value) & "<br>" Response.Write("Password: " & dbc.objRS("password").value) & "<br><br>" Loop dbc.Close() Code (markup):
Is this in .net? I am using classic asp. Here is the code I have: <% Dim Conn Dim rs Dim sql Set Conn = Server.CreateObject("ADODB.Connection") Conn.Provider = "Microsoft.Jet.OLEDB.4.0" Conn.ConnectionString = "Data Source=" & Server.MapPath ("db1.mdb") Conn.Open Set rs = Server.CreateObject("ADODB.Recordset") sql = "SELECT record.* FROM record WHERE date=Now();" Rs.Open sql, Conn, 1,3 rs.Delete sql = "SELECT record.link,record.date FROM record WHERE category='travel' AND store='hotels.com' ORDER BY date;" Do While not rs.EOF %> <table width="100%" border="1"> <tr><td><a href= "<%=rs("link")%>"><%=rs("link")%></a> </td> <td> <% Response.Write rs("Date") %> </td> </tr> <% rs.MoveNext Loop %> </table> And I am getting an error: ADODB.Recordset error '800a0bcd' Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. /data.asp, line 23 <% rs.Close Set rs = Nothing Conn.Close Set Conn = Nothing %> Code (markup):
this recordset stuff is out of the Ark. You should be executing one sql query to delete the records you don't want and then another query to return the records you want to display.
Maybe try this: <% Dim Conn Dim rs Dim sql Set Conn = Server.CreateObject("ADODB.Connection") Conn.Provider = "Microsoft.Jet.OLEDB.4.0" Conn.ConnectionString = "Data Source=" & Server.MapPath ("db1.mdb") Conn.Open Set rs = Server.CreateObject("ADODB.Recordset") sql = "SELECT record.* FROM record WHERE date=Now();" Rs.Open sql, Conn, 1,3 Rs.Delete Rs.Update Rs.Close sql = "SELECT record.link,record.date FROM record WHERE category='travel' AND store='hotels.com' ORDER BY date;" Rs.Open sql, Conn, 1,3 Do While not rs.EOF %> <table width="100%" border="1"> <tr><td><a href= "<%=rs("link")%>"><%=rs("link")%></a> </td> <td> <% Response.Write rs("Date") %> </td> </tr> <% rs.MoveNext Loop %> </table> <% rs.Close Set rs = Nothing Conn.Close Set Conn = Nothing %> Code (markup):
I haven't tested the above code, but you needed to Update the recordset, then close it, and then re-open it with the new sql query.