Solved

Input of "SQL server Authentication password" via dialoge box

Posted on 2014-04-25
3
306 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
Comment Utility
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
Comment Utility
0
 

Author Closing Comment

by:lieka
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
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

772 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

10 Experts available now in Live!

Get 1:1 Help Now