Solved

Input of "SQL server Authentication password" via dialoge box

Posted on 2014-04-25
3
315 Views
Last Modified: 2014-05-14
When creating a datasource (dataset) with help of the wizard in Visual Studio one has the option of not storing password data in the connectionstring being saved in the config-xml-file. If I choose to "....set this information in my application code."; Can anybody refer me to a sample where the input of a "SQL server Authentication password" is handled by a dialogbox? The thing that I cannot figure out is what property should I set using the password input I get. I would hope that there is a smarter solution than setting the password-part of the connectionstring of each of the commands for every tableadapter in my dataset?
0
Comment
Question by:lieka
  • 2
3 Comments
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 500 total points
ID: 40022386
You'll need to set it for the connection on the TableAdapter prior to use. If you cheat a little and change the connection in the config to contain a placeholder for the password:

i.e.
<add name="ConsoleApplication1.Properties.Settings.DemoConnectionString"
            connectionString="Data Source=(local);Initial Catalog=Demo;User ID=AUser;PWD={0}"
            providerName="System.Data.SqlClient" />

Open in new window

Then you can do something like:
DemoDataSetTableAdapters.DemoTableAdapter adap = new DemoDataSetTableAdapters.DemoTableAdapter();
adap.Connection.ConnectionString = string.Format(adap.Connection.ConnectionString, "thePassword");

Open in new window

0
 

Accepted Solution

by:
lieka earned 0 total points
ID: 40054461
0
 

Author Closing Comment

by:lieka
ID: 40064018
The technique intercepts the reading og the connectionstring time from settings . IT it this possible to  supply your additions to the connectionstring before returning the value. I had to use a password function to be able to store the obtained password as static variable within the function.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question