Solved

Input of "SQL server Authentication password" via dialoge box

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

809 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