Click here to Skip to main content
15,888,100 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to add a password to my connection string that opens my Access file which is password protected.

I have done this before in the Form1.cs but cant figure it out in XML

I have a password dialog the user enters a password but it want open the access file
because it has a password on it


C#
<pre><?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
    </configSections>
    <connectionStrings>
        <add name="Employee_List.Properties.Settings.Database5ConnectionString"
            connectionString= "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database5.accdb"
            providerName="System.Data.OleDb" />
    
    </connectionStrings>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>
</configuration>



private void Form1_Load_1(object sender, EventArgs e)
{

    // TODO: This line of code loads data into the 'database5DataSet.Employee' table. You can move, or remove it, as needed.
    this.employeeTableAdapter.Fill(this.database5DataSet.Employee);

}


What I have tried:

Searching Appconfig and connection strings
Posted
Updated 19-Apr-19 9:37am
v2
Comments
Arkadeep De 6-Apr-19 10:57am    
What you have done in your form1.cs? And what do you want to achive?? Can you pls eleborate??
Richard MacCutchan 6-Apr-19 11:00am    
No, you should never put passwords in code or config files. Use a simple dialog that the user must provide it at run time.
Member 12349103 6-Apr-19 11:19am    
I have a dialog with a password

1 solution

I know this is a bit late to give an answer but I would have a look at this, there is a section in the called With database password

Access connection strings - ConnectionStrings.com[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900