Solved

Input of "SQL server Authentication password" via dialoge box

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

943 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now