Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / May 2007

Tip: Looking for answers? Try searching our database.

Programmatically setting SqlServer vs. Windows authentication

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
michael sorens - 10 May 2007 22:11 GMT
I am wondering how to programmatically select either SqlServer or Windows
authentication when connecting to a database. Is this something in the
connection string? Or is it some other parameter to a connection method...?
Marc Gravell - 10 May 2007 22:31 GMT
> Is this something in the connection string?
Yes. See here: http://www.connectionstrings.com/?carrier=sqlserver2005
(scroll to SqlConnection)

Marc
Nicholas Paldino [.NET/C# MVP] - 10 May 2007 22:44 GMT
Michael,

   Yes, it is in the connection string.  To facilitate generating this
programatically, take a look at the SqlConnectionStringBuilder class in the
System.Data.SqlClient namespace.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

>I am wondering how to programmatically select either SqlServer or Windows
> authentication when connecting to a database. Is this something in the
> connection string? Or is it some other parameter to a connection
> method...?
michael sorens - 14 May 2007 17:21 GMT
Both replies so far contain useful information on this topic; however they do
not really help me with my base question. Perhaps a specific example may
clarify. Let's say that I want to connect to AdventureWorks. I know that this
string works using Windows Authentication:

Data Source=.\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated
Security=True

Now let's say I create a new SQL user and want to change to SqlServer
authentication. So I add the "User ID" and "Password" attributes to the
connection string. Is that all it takes? Do I need to add other attributes?
Or remove the "Integrated Security" ...?
Marc Gravell - 14 May 2007 20:06 GMT
Add the username & password; remove the integrated security. Job done.

Marc
PhilipDaniels@foo.com - 15 May 2007 09:43 GMT
>Both replies so far contain useful information on this topic; however they do
>not really help me with my base question. Perhaps a specific example may
[quoted text clipped - 8 lines]
>connection string. Is that all it takes? Do I need to add other attributes?
>Or remove the "Integrated Security" ...?

There are so many variations of connection strings it is easy to
forget exactly what you need...I find the following resource helpful

http://carlprothman.net/Default.aspx?tabid=81

--
Philip Daniels
Walter Wang [MSFT] - 17 May 2007 13:10 GMT
Hi,

As other community members suggested, you will need to remove the
"Integrity Security" and add "User ID"/Password to make it use sqlserver
authentication.

Please feel free to let us know if there's still anything unclear. Thanks.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.