none
Advanced DataGridView with Excel-Like AutoFilter Connection Problem to Access Database RRS feed

  • Question

  • Hi everyone,

    I would like to consult you about something I could not find on the Internet. A few days ago, I started to use "Advanced DataGridView with Excel-like Auto Filter" in my project.

    I downloaded it via Manage NuGet Packages section in Visual Studio 2017. The algorithm was developed by ADGV (https://adgv.codeplex.com/)
    It works absolutely great in terms of filtering and sorting the data which is coming from a non-encrypted access database. 

    However, today I decided to encrypt the same database and then when I started to run my code in Microsoft Visual Studio 2017, it gave an error as follows; 

    System.Data.OleDb.OleDbException: 'Invalid Password.'

    I must put mypassword inside the following code, but I could not manage it beacuse I don't know how to place a password defining code inside it.


    // TODO: This line of code loads data into the 'dENEMEDataSet.Tablo1' table
    this.tablo1TableAdapter.Fill(this.dENEMEDataSet.Tablo1);


    Can someone please help me on that issue??

    Note: dENEME is the name of my access database file and tablo1 is the name of my table in that access file

    • Moved by Stanly Fan Monday, August 28, 2017 8:07 AM
    Saturday, August 19, 2017 6:57 PM

All replies

  • Hi AYKUT,

    For your question, I suggest you ask the author of the algorithm here.

    In fact, the DataGridView columns already support sorting.

    I would populate a DataTable with your data and then bind the DataGridView to myDataTable.DefaultView.

    You can filter the rows displayed by setting myDataTable.DefaultView.RowFilter.

    You could place Textboxes and/or Comboboxes above the DataGridView and update myDataTable.DefaultView.RowFilter as the input/selections change.

    Refer: C# Winforms DataGridView with sorting/filtering like Ms Excel.

    Also there is a document in MSDN: Building a Drop-Down Filter List for a DataGridView Column Header Cell.

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best Regards,

    Stanly


    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.

    Monday, August 21, 2017 7:48 AM
  • Hello,

    You can alter your app.config file to include your password as shown below.

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
        </configSections>
        <connectionStrings>
            <add name="WindowsFormsApp2.Properties.Settings.Database1ConnectionString"
                connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database1.accdb;Persist Security Info=True;Jet OLEDB:Database Password=password"
                providerName="System.Data.OleDb" />
        </connectionStrings>
        <startup> 
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
        </startup>
    </configuration>

    Then encrypt the app.config file which I shown in my MSDN code sample. For clarity, I include the class ConnectionProtection which requires you to add a reference to System.configuration, I create a new instance of the class as a private variable.

    using System;
    using System.Windows.Forms;
    
    namespace WindowsFormsApp2
    {
        public partial class Form1 : Form
        {
            ConnectionProtection operations =
                     new ConnectionProtection(Application.ExecutablePath);
            public Form1()
            {
                InitializeComponent();
            }
    
            private void customersBindingNavigatorSaveItem_Click(object sender, EventArgs e)
            {
                this.Validate();
                this.customersBindingSource.EndEdit();
                this.tableAdapterManager.UpdateAll(this.database1DataSet);
    
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                // The following line is needed once to encypt.
                operations.EncryptFile();
                // This decrypts the file
                operations.DecryptFile();
                // TODO: This line of code loads data into the 'database1DataSet.Customers' 
                // table. You can move, or remove it, as needed.
                this.customersTableAdapter.Fill(this.database1DataSet.Customers);
                // re-encrypt
                operations.EncryptFile();
            }
        }
    }
    

    The runtime version of app.config as encrypted.

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
        </configSections>
        <connectionStrings configProtectionProvider="DataProtectionConfigurationProvider">
            <EncryptedData>
                <CipherData>
                    <CipherValue>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAyY9p9xYMRU+C+8fmJZLTMgQAAAACAAAAAAADZgAAwAAAABAAAABOOnhD8cIYJFuw35uqFA7rAAAAAASAAACgAAAAEAAAAB0e/aRPNqpgXaECINQHJcGAAgAA27FZFmqvitLPP84TRyP/CdB7h9V4o1gHwd7TCkTLMixhRlZCOZ5w++k8y8BTHOcNoRBdjvII5t0CZPjdDEcrherTbp2r9UyiLqPACCjMQUzHUw5RcomZ/z+AjtMoWZVGSz5FtqBu7/mM6sPjU40aRAl4f/vM949jhb/TAniQZlUvrYx/s5iqoYW6gAdAoo/oxYHaRuGcswmApxzLpXrsolo5xbpmMdQhnD569kXFHYlwf4+CbuBj3Pz8Ao+bCHuWYIPHzU9AQiSDOdLLIZ8Mgne148YhhKiFuwXsMUxpS66kMB/vQAjatT7Kz0Il8SPI5pp+0uHkyFF0Swc4DzLin7hIknQzrmQ2jcw3E2ddE+viaGxNSLy+TJfhdIED4B3PxrTXUwpdJxILyeZba4875dtZhpJT2OwXP0oegk+qdH0J9A7xh+oX0pKAsS1iu/JdHR6e/6fCzCqm3Nf+yRaU+K7aKENeMwsZdtDgWwE9qvfP1+fzQzkblgP8KviXUhH/OQAJmnD5vo+KRmKhhcQIri2/fQERj/wbFmBURLSfl3+gcRGNOWWlaySCu9UcQm1uVwq+dCKKa9DCaA/lR9P+jdv0jQILaDSezkuoT258BG+1WJV29bfZQ1rAiDb/DBWMe0N1u5mDhaTD/sP4zJDZa0UuN3ZZAoMDVWfFqUuAPbyr5UYJXsyLghG4MmClYX6cJXogbGqlITsmqFBe7tQxIPdh80TT3R0crzQbTEQWZJy/FUc+i0Zx2wxDmFAMImkZt7iHjA+GA4a3KpW/rcN0rTgcAS52ZIBN/WTQSY2XOhWK7fic6H1VDIwn7beuONR18+CqzxxoJ79LVEcDxBWHCRQAAAC3BQp6vwj9b8ESEwJ3n5UrhYY5vQ==</CipherValue>
                </CipherData>
            </EncryptedData>
        </connectionStrings>
        <startup> 
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
        </startup>
    </configuration>


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Proposed as answer by Stanly Fan Thursday, August 24, 2017 7:11 AM
    Monday, August 21, 2017 12:56 PM