Reputation: 1177
I am making a simple c#.net winform application which will connect to sql server. I wnat it to have 2 ways to connect- Windows Authentication and SQL server Authentication.
From what I found online I came up so far with:
public static void SetConnectionStringParams(string dbAddress, bool isWinAuth, string user, string password)
{
if (isWinAuth)
{
_connectionString =
string.Format(
"Data Source={0};Database = {1};Integrated Security=True;Max Pool Size=1000;MultipleActiveResultSets=True;Connection Timeout=60",
dbAddress, DefaultDBname);
}
else
{
_connectionString =
string.Format(
"Data Source={0};Database = {1};User ID={2};Password={3};Max Pool Size=1000;MultipleActiveResultSets=True;Connection Timeout=60",
dbAddress, DefaultDBname, user, password);
}
}
which works great, but I couldn't found how in case of Windows Auth I force require user and password instead of using the Integrated Security=True
...
Is there an API that do that? if not, would appreciate guidance how to do it.
Thank you,
Upvotes: 0
Views: 2605
Reputation: 1924
Give this a shot
Upvotes: 1