none
Add pdf document in accesdatabase RRS feed

Answers

  • ciao dokirt,2

    the best way is absolutely to enter just the full path in a field of table and keeping all files into a folder in your hard disk.

    you can manipulate them, opening, Printing, moving into other folders just by the path.

    HTH.

    Ciao, Sandro.

    • Marked as answer by dokirt.2 Wednesday, December 27, 2017 8:01 AM
    Monday, December 25, 2017 5:09 PM
  • Hi dokirt.2,

    I agree with the suggestion given by Sandro Peruz regarding storing the path of file in Access Database instead of storing whole file itself.

    the reason is MS Access Database comes with limit of 2 GB size.

    if your PDF file are big in size or you are storing many PDF files in database then it is possible that your database soon reach the limit of 2 GB.

    after that you are not able to store more data in that database.

    so if you just store the path of file then you can store huge amount of data without worrying about the size limit of database.

    because path is stored as text in database which occupy extremely less amount of space.

    every method has some pros and cons , you can find it below.

    Pros of storing the files in File system:
    (1) Performance can be better than doing it in db. To justify this, If you store large files in db then it may slow down the performance because a simple query to retrieve the list of files or filename will also load the file data if you used Select * in your query. While Files system accessing a file is quite simple and light weight.

    (2) Saving the files and downloading them in the file system is much simpler than database since a simple Save as function will help you out. Downloading can be done by addressing an URL with the location of the saved file.

    (3) Migrating the data is an easy process here. You can just copy and paste the folder to your desired destination while ensuring that write permissions are provided to your destination.

    Cons of storing the files in File system:
    (1) Loosely packed. No ACID (Atomicity, Consistency, Isolation, Durability) operations relational mapping which mean there is no guarantee. Consider a scenario if your files are deleted from the location manually or by some hacking dudes, you might not know whether the file exists or not. Painful right?

    (2) Low Security. Since your files can be saved in a folder where you should have provided write permissions, it is prone to safety issues and invites troubles like hacking. So it is best to avoid saving in fs if you cannot afford to compromise in terms of security.

    Pros of storing the files in Database:
    (1) ACID consistency which includes a rollback of an update that is complicated when the files are stored outside the database.

    (2) Files will be in sync with the database so cannot be orphaned from it which gives you an upper hand in tracking transactions.

    (3) Backups automatically include file binaries.

    (4) More Secure than saving in a File System.

    Cons of storing the files in Database:

    (1) Database Backups will become more hefty and heavy.

    (2) read/write to a DB is always slower than a filesystem.

    (3) your DB backups grow to be huge and more time consuming

    so you can refer the points above and take the decision which is best suitable for your requirement.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by dokirt.2 Tuesday, December 26, 2017 7:02 AM
    Tuesday, December 26, 2017 1:39 AM
    Moderator
  • Hi dbacc,

    you had asked," how i canstore the path of file in Access via c#?"

    below is the sample example:

    using System.Data.OleDb;
    
    
      private void button1_Click(object sender, EventArgs e)
            {
                var DBPath = @"D:\16-3-20017 backup desktop\dbacc.mdb";
    
              var  conn = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;" + "Data Source=" + DBPath);
                conn.Open();
               
                string path = @"C:\Users\v-padee\Desktop\image\dws.png";
                using (OleDbCommand cmd = new OleDbCommand("INSERT INTO img_data(img_path) VALUES('" + path + "');", conn))
                {
                    cmd.ExecuteNonQuery();
                }
            }

    Output:

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by dokirt.2 Wednesday, December 27, 2017 8:01 AM
    Wednesday, December 27, 2017 6:58 AM
    Moderator
  • Hi dokirt.2,

    you can try to copy the file from one location to other location like below.

    string FileToCopy = null;
    string NewCopy = null;
     
    FileToCopy = "C:\\Users\\Owner\\Documents\\test.txt";
    NewCopy = "C:\\Users\\Owner\\Documents\\NewTest.txt";
     
    
    if (System.IO.File.Exists(FileToCopy) == true) {
        System.IO.File.Copy(FileToCopy, NewCopy);
        Interaction.MsgBox("File Copied");
     
    }

    further you can make a test and modify it according to your requirement.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by dokirt.2 Wednesday, December 27, 2017 8:01 AM
    Wednesday, December 27, 2017 7:22 AM
    Moderator

All replies

  • ciao dokirt,2

    the best way is absolutely to enter just the full path in a field of table and keeping all files into a folder in your hard disk.

    you can manipulate them, opening, Printing, moving into other folders just by the path.

    HTH.

    Ciao, Sandro.

    • Marked as answer by dokirt.2 Wednesday, December 27, 2017 8:01 AM
    Monday, December 25, 2017 5:09 PM
  • Hi dokirt.2,

    I agree with the suggestion given by Sandro Peruz regarding storing the path of file in Access Database instead of storing whole file itself.

    the reason is MS Access Database comes with limit of 2 GB size.

    if your PDF file are big in size or you are storing many PDF files in database then it is possible that your database soon reach the limit of 2 GB.

    after that you are not able to store more data in that database.

    so if you just store the path of file then you can store huge amount of data without worrying about the size limit of database.

    because path is stored as text in database which occupy extremely less amount of space.

    every method has some pros and cons , you can find it below.

    Pros of storing the files in File system:
    (1) Performance can be better than doing it in db. To justify this, If you store large files in db then it may slow down the performance because a simple query to retrieve the list of files or filename will also load the file data if you used Select * in your query. While Files system accessing a file is quite simple and light weight.

    (2) Saving the files and downloading them in the file system is much simpler than database since a simple Save as function will help you out. Downloading can be done by addressing an URL with the location of the saved file.

    (3) Migrating the data is an easy process here. You can just copy and paste the folder to your desired destination while ensuring that write permissions are provided to your destination.

    Cons of storing the files in File system:
    (1) Loosely packed. No ACID (Atomicity, Consistency, Isolation, Durability) operations relational mapping which mean there is no guarantee. Consider a scenario if your files are deleted from the location manually or by some hacking dudes, you might not know whether the file exists or not. Painful right?

    (2) Low Security. Since your files can be saved in a folder where you should have provided write permissions, it is prone to safety issues and invites troubles like hacking. So it is best to avoid saving in fs if you cannot afford to compromise in terms of security.

    Pros of storing the files in Database:
    (1) ACID consistency which includes a rollback of an update that is complicated when the files are stored outside the database.

    (2) Files will be in sync with the database so cannot be orphaned from it which gives you an upper hand in tracking transactions.

    (3) Backups automatically include file binaries.

    (4) More Secure than saving in a File System.

    Cons of storing the files in Database:

    (1) Database Backups will become more hefty and heavy.

    (2) read/write to a DB is always slower than a filesystem.

    (3) your DB backups grow to be huge and more time consuming

    so you can refer the points above and take the decision which is best suitable for your requirement.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by dokirt.2 Tuesday, December 26, 2017 7:02 AM
    Tuesday, December 26, 2017 1:39 AM
    Moderator
  • thank you for this comprehensive answer, but now i have another question, how i canstore the path of file in Access via c#?

    • Edited by dokirt.2 Tuesday, December 26, 2017 7:06 AM
    • Marked as answer by dokirt.2 Wednesday, December 27, 2017 8:01 AM
    • Unmarked as answer by dokirt.2 Wednesday, December 27, 2017 8:01 AM
    Tuesday, December 26, 2017 7:04 AM
  • Hi dbacc,

    you had asked," how i canstore the path of file in Access via c#?"

    below is the sample example:

    using System.Data.OleDb;
    
    
      private void button1_Click(object sender, EventArgs e)
            {
                var DBPath = @"D:\16-3-20017 backup desktop\dbacc.mdb";
    
              var  conn = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;" + "Data Source=" + DBPath);
                conn.Open();
               
                string path = @"C:\Users\v-padee\Desktop\image\dws.png";
                using (OleDbCommand cmd = new OleDbCommand("INSERT INTO img_data(img_path) VALUES('" + path + "');", conn))
                {
                    cmd.ExecuteNonQuery();
                }
            }

    Output:

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by dokirt.2 Wednesday, December 27, 2017 8:01 AM
    Wednesday, December 27, 2017 6:58 AM
    Moderator
  • Can i add this  pdf  files in one folder inside my project folder?

    ES

    Wednesday, December 27, 2017 7:01 AM
  • Hi dokirt.2,

    you can try to copy the file from one location to other location like below.

    string FileToCopy = null;
    string NewCopy = null;
     
    FileToCopy = "C:\\Users\\Owner\\Documents\\test.txt";
    NewCopy = "C:\\Users\\Owner\\Documents\\NewTest.txt";
     
    
    if (System.IO.File.Exists(FileToCopy) == true) {
        System.IO.File.Copy(FileToCopy, NewCopy);
        Interaction.MsgBox("File Copied");
     
    }

    further you can make a test and modify it according to your requirement.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by dokirt.2 Wednesday, December 27, 2017 8:01 AM
    Wednesday, December 27, 2017 7:22 AM
    Moderator