1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

get hyperlink form MS Access in ASP?

Discussion in 'C#' started by akinak, Nov 8, 2008.

  1. #1
    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?
     
    akinak, Nov 8, 2008 IP
  2. sampathsl

    sampathsl Guest

    Messages:
    861
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Please try this
    Response.write "<a href=" & Rec("Web_Link") & ">"
     
    sampathsl, Nov 8, 2008 IP
  3. akinak

    akinak Peon

    Messages:
    256
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    dosen't works..sorry
     
    akinak, Nov 9, 2008 IP
  4. ranabra

    ranabra Peon

    Messages:
    125
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    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
     
    ranabra, Nov 10, 2008 IP
  5. akinak

    akinak Peon

    Messages:
    256
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    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.
     
    akinak, Nov 11, 2008 IP
  6. islandhopper8

    islandhopper8 Active Member

    Messages:
    100
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    73
    #6
    it might be a solution to put all the information in a regular field or change the properties for column from hyperlink to text.
     
    islandhopper8, Nov 11, 2008 IP
  7. akinak

    akinak Peon

    Messages:
    256
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I cannot do that..because there is a limit of 255 characters for that field. My links are going to be longer.
     
    akinak, Nov 11, 2008 IP
  8. akinak

    akinak Peon

    Messages:
    256
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    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.
     
    akinak, Nov 11, 2008 IP
  9. Nytrolic

    Nytrolic Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Put the URL's into a longtext type field in the database and try something like this

    <a href="<%=rs("URL")%>"><%=rs("URLTEXT")%></a>
     
    Nytrolic, Nov 13, 2008 IP
  10. akinak

    akinak Peon

    Messages:
    256
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    How to specify longtext type field in MS Access?
     
    akinak, Nov 13, 2008 IP
  11. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #11
    Try changing the field type to 'Memo' in MS Access
     
    camjohnson95, Nov 13, 2008 IP
  12. akinak

    akinak Peon

    Messages:
    256
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    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?
     
    akinak, Nov 15, 2008 IP
  13. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #13
    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):
     
    camjohnson95, Nov 15, 2008 IP
  14. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #14
    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):
     
    camjohnson95, Nov 15, 2008 IP
  15. akinak

    akinak Peon

    Messages:
    256
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    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):
     
    akinak, Nov 16, 2008 IP
  16. web-bod

    web-bod Guest

    Messages:
    17
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #16
    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.
     
    web-bod, Nov 16, 2008 IP
  17. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #17
    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):
     
    camjohnson95, Nov 17, 2008 IP
    akinak likes this.
  18. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #18
    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.
     
    camjohnson95, Nov 17, 2008 IP
  19. akinak

    akinak Peon

    Messages:
    256
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #19
    camjohnson95 - this does works. Thanks a lot for your help. rep added. :)
     
    akinak, Nov 24, 2008 IP
  20. akinak

    akinak Peon

    Messages:
    256
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    camjohnson95 - it does works. Thanks a lot for your help. rep added :)
     
    akinak, Nov 24, 2008 IP