Add new datasource from a database with a password

AndyNakamura 51 Reputation points
2021-07-30T07:20:41.733+00:00

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?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,648 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,668 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Karen Payne MVP 35,386 Reputation points
    2021-07-30T09:51:20.463+00:00

    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.

    0 comments No comments