locked
How to Save Hyperlink in Access Database RRS feed

  • Question

  • User-193610214 posted

     I have a form where a user enters their name, date etc.
    i also want them to be able to click on a browse button and select a
    file which will then appear in a textbox. when they press submit i
    want the file name and path to be put into the database. e.g.
    "C:\windows\work\work.doc". Basically I don't want to UPLOAD the file
    just enable the user to browse to it and send the filename and path to
    the database.

    Friday, May 28, 2010 2:50 AM

Answers

  • User551462331 posted

    i m really not sure about the issue u r pointing to...

    if u just want to save file path mentioned in textbox into database using accessdatasource, then try this

    change insertparameter tag in accessdatasource tag as....

    create textbox control on page as, txt_Image_Path

    <insertparameters>
                 <asp:Parameter Name="MemoCol" Type="String" />
                 <asp:formparameter Name="HyperCol" formfield="txt_Image_Path" />
                 <asp:Parameter Name="CurrCol" Type="Decimal" />
                 <asp:Parameter Name="LinkID" Type="Int32" />

    </insertparameters> 

    this MSDN may help u

    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.insertcommand.aspx

    try to write file path in txt_Image_Path textbox and verify if its saved properly..... if done... u can implement my first post...(hidden box to store file selectd by fileupload control... u can simply hide textbox txt_Image_Path then..)

    let me know if it works for u..

    hope this helps...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 1, 2010 3:11 PM

All replies

  • User-821857111 posted

    Why do you want to store the local path in your database? The file path on the user's machine is useless to you, isn't it? Apart from that, getting the file path of the user's file is not always possible without them actually entering it in the textbox.


    Friday, May 28, 2010 3:16 AM
  • User551462331 posted

    i guess u should first notice point made by mike...

    still... u can do it like this..

    write following javascript function on the page in head section

  •     function GetFileName(evt)   
  •     {   
  •         document.getElementById("txtHiddenFileName").value = evt;
  •     }   

    add following control on the page

    <asp:FileUpload ID="FileUpload1" runat="server" Width="514px" onchange="javascript:AddToList(this.value);" style="display:none;"/>  

    and another hidden textbox which is referred in javascript function above

    <asp:TextBox id="txtHiddenFileName" runat="server">

    on button click, try to remove file name from fileupload control. so that file wont be uploaded. but we already have stored selected file name in hidden textbox and u can read the file name from that textbox in codebehind...

    hope this helps....

Friday, May 28, 2010 3:33 AM
  • User-193610214 posted

    Actually, I 'm not require to upload the file.  I have another form for user search documents which has been saved in the various folders of server.   In this connection, user could retrieve the hyplink from database base on their input parameters.  Please advise how to save URL in the TextBox. 

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">

    <html>

     <title>upload</title>

    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <br />
              Name:    <asp:TextBox id="txt_Image_Name" runat="server"></asp:TextBox>
        <br />
           Image Path:  <asp:FileUpload ID="FileUpload1" runat="server" Width="514px"/>
          <br />

            <asp:Button runat="server" ID="cmd_Upload" Text="Save" OnClick="cmd_Upload_Click" /> 

         <asp:AccessDataSource ID="AccessDataSource1" runat="server"
                DataFile="~/App_Data/database2000.mdb"
               
                  SelectCommand="SELECT [MemoCol], [HyperCol], [CurrCol], [LinkID] FROM [Hyper] WHERE ([HyperCol] = ?)"
                  DeleteCommand="DELETE FROM [Hyper] WHERE [LinkID] = ?"
                  InsertCommand="INSERT INTO [Hyper] ([MemoCol], [HyperCol], [CurrCol], [LinkID]) VALUES (?, ?, ?, ?)"
                  UpdateCommand="UPDATE [Hyper] SET [MemoCol] = ?, [HyperCol] = ?, [CurrCol] = ? WHERE [LinkID] = ?">
             <SelectParameters>
                 <asp:ControlParameter ControlID="txt_Image_Name" Name="HyperCol"
                     PropertyName="Text" Type="String" />
             </SelectParameters>
             <DeleteParameters>
                 <asp:Parameter Name="LinkID" Type="Int32" />
             </DeleteParameters>
             <UpdateParameters>
                 <asp:Parameter Name="MemoCol" Type="String" />
                 <asp:Parameter Name="HyperCol" Type="String" />
                 <asp:Parameter Name="CurrCol" Type="Decimal" />
                 <asp:Parameter Name="LinkID" Type="Int32" />
             </UpdateParameters>
             <InsertParameters>
                 <asp:Parameter Name="MemoCol" Type="String" />
                 <asp:Parameter Name="HyperCol" Type="String" />
                 <asp:Parameter Name="CurrCol" Type="Decimal" />
                 <asp:Parameter Name="LinkID" Type="Int32" />
             </InsertParameters>
            </asp:AccessDataSource>
        </div>
        </form>
    </body>
    </html>

     Protected Sub cmd_Upload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmd_Upload.Click

            AccessDataSource1.Insert()
        End Sub
    End Class

    Saturday, May 29, 2010 4:51 AM
  • User551462331 posted

    i m really not sure about the issue u r pointing to...

    if u just want to save file path mentioned in textbox into database using accessdatasource, then try this

    change insertparameter tag in accessdatasource tag as....

    create textbox control on page as, txt_Image_Path

    <insertparameters>
                 <asp:Parameter Name="MemoCol" Type="String" />
                 <asp:formparameter Name="HyperCol" formfield="txt_Image_Path" />
                 <asp:Parameter Name="CurrCol" Type="Decimal" />
                 <asp:Parameter Name="LinkID" Type="Int32" />

    </insertparameters> 

    this MSDN may help u

    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.insertcommand.aspx

    try to write file path in txt_Image_Path textbox and verify if its saved properly..... if done... u can implement my first post...(hidden box to store file selectd by fileupload control... u can simply hide textbox txt_Image_Path then..)

    let me know if it works for u..

    hope this helps...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 1, 2010 3:11 PM