question

AndyNakamura-7969 avatar image
0 Votes"
AndyNakamura-7969 asked karenpayneoregon answered

Add new datasource from a database with a password

I'm trying to use the 'Add new datasource' feature in vb.net to create a dataset so I can just drag the dataset onto my form as a datagrid.
The dataset comes from a .accdb database with a password.
I'm wanting to use the wizard because it is much easier to keep things synchronized to each other.

I don't know how to handle the password though as it is generated from a user login and not stored in the application at all.
In the past I've always done this from code.
ie.
passed the password manually to the connection string and created a dataset with an sql statement and set the datagrid.datasource to the dataset.

Anyone know how to handle passwords when using the wizard?

dotnet-csharpdotnet-visual-basic
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

karenpayneoregon avatar image
0 Votes"
karenpayneoregon answered

About the only way for this to work is

  • Create a database password then when using the wizard you should be prompted for a password. Store the database connection string in app.config encrypted.

  • Store user name and password in the database

Code sample for Access/VB

For SQL-Server which is more work but with that better security. See my TechNet article for more details

SQL Server database login for Windows Forms

When a database is protected by a password and Visual Studio wizard is used Visual Studio will prompt for credentials. For me with SQL-Server when working with a group in an company AD group for permissions can be a decent option while for individuals setting up users in SQL-Server or via Windows authentication is best and again Visual Studio will respect that.

Have not worked with MS-Access in years so not sure if Visual Studio will allow you to store the password when setting up a data source in Server Explorer but will for SQL-Server and Oracle.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.