locked
Managing database RRS feed

  • Question

  • User1870962266 posted

    hi, i am new to this . I have to create search engine and database. Suppose , In the database we have to upload list of files from hard disk to local sever and If i search for certain file, i have to select it and download the file.

    Thanks

    search engine

         data base

    download
    Tuesday, September 4, 2018 8:41 AM

All replies

  • User753101303 posted

    Hi,

    If you mean the search is based on the file content you have full text search capabilities as part of the database (for example https://docs.microsoft.com/en-us/sql/relational-databases/search/full-text-search?view=sql-server-2017 with SQL Server) or you could use a 3rd part engine : https://en.wikipedia.org/wiki/Full-text_search#Software

    Edit: ah or depending on how it is hosted (you have full control on the hosting server ?) and if you want to keep using Access (really ?) you could try to take advantage of the Windows desktop search : https://docs.microsoft.com/en-us/windows/desktop/search/windows-search

    Tuesday, September 4, 2018 10:43 AM
  • User1870962266 posted

    Hi,

    thanks for reply. I have hard disk with list of files( example: text files) and connected to local server , and i have to upload files to database and download it. Suppose in search engine , i wrote letter ´a`´ then in database all files with letter ´ a ´ has to visible and i have to select the file and download it

    Tuesday, September 4, 2018 11:46 AM
  • User753101303 posted

    "with letter" but where exactly ? So it seems you'll just search in the file name and not in the file content ?

    For example you could start with https://floatincode.net/blog/sql-file-stream-in-asp.net-mvc-with-entity-framework/ as anyway you'll need to store files (btw you are using Web Forms or MVC ?)

    For now the problem is just about the search or are you new as well about uploading/downloading files ?

    Tuesday, September 4, 2018 12:06 PM
  • User1870962266 posted

    Yes, I will search with file names. I have list of files in a hard disk, I have to upload it to the database(local server) and i have to download the file which i want to download. That means, I know  uploading/downloading files.

    Wednesday, September 5, 2018 7:49 AM
  • User753101303 posted

    So the problem is rather with searching a string inside file names ? I would expect them to be stored in a db column. And you would need a SQL where criteria such as name LIKE '%'+@search+'%' in your SQL criteria (might be a bit different for Access).

    Please be more explicit about the very first issue you have in trying to do what you describe so that we can focus on that first problem you have. The upload part is ok ?

    Wednesday, September 5, 2018 8:26 AM
  • User1870962266 posted

    I dont know how to upload files . I think SQL is not useful for this one.

    Wednesday, September 5, 2018 8:43 AM
  • User753101303 posted

    This is done very often and you should find tons of tutorials about doing that. Try https://www.mikesdotnetting.com/article/123/storing-files-and-images-in-access-with-asp-net

    With recent version you can also handle uploading multiple files with a single FileUpload control.

    Wednesday, September 5, 2018 8:51 AM
  • User1870962266 posted

    i don't like to create SQL database. I have to upload files (text,PDF) to database . If i am searching for a file ,  i have to select and download that file from my database.

    a

    art.txt

    array.txt

    ast.pdf

    Like this figure , i have to do. Here i am searching for `a ´ then in database all files with letter `a`  are shown.

    thanks

    Wednesday, September 5, 2018 10:47 AM
  • User283571144 posted

    Hi price96,

    i don't like to create SQL database. I have to upload files (text,PDF) to database . If i am searching for a file ,  i have to select and download that file from my database.

    According to your description, I couldn't understand your requirement clearly.

    Do you mean the database is the server?

    If you just want to search the file in asp.net, you could use DirectoryInfo.GetFiles to achieve your requirement.

    More details, you could refer to below codes:

    Notice: If you want to download the file by using the url, you should make sure the folder is insider your web application's root folder.

    ASPX:

            <div>
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
                <asp:GridView ID="GridView1" runat="server">
    
                </asp:GridView>
            </div>

    Code-behind:

    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.IO;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace WebFormTest
    {
        public partial class SearchFile : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
         
            }
    
            protected void Button1_Click(object sender, EventArgs e)
            {
                DataTable d1 = new DataTable();
                d1.Columns.Add("FileName");
                d1.Columns.Add("FilePath");
    
                string partialName = TextBox1.Text;
                //modify the folder according to your requirement
                DirectoryInfo hdDirectoryInWhichToSearch = new DirectoryInfo(@"D:\image");
                FileInfo[] filesInDir = hdDirectoryInWhichToSearch.GetFiles("*" + partialName + "*.*");
    
                foreach (FileInfo foundFile in filesInDir)
                {
                    d1.Rows.Add(foundFile.Name, foundFile.FullName);      
                }
    
                GridView1.DataSource = d1;
                GridView1.DataBind();
    
            }
        }
    }

    Result:

    Best Regards,

    Brando

    Tuesday, September 11, 2018 7:01 AM