Solved

Input of "SQL server Authentication password" via dialoge box

Posted on 2014-04-25
3
316 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

685 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