Как мне изменить этот источник данных из этой строки
`String constr = (@"Data source=(localdb)\MSSQLLocalDB; initial catalog=DataHRD; integrated security=true;");`
(localdb)\MSSQLLocalDB ==> C:\Users\SONY\Desktop\asda\asd\MainMenu\DataHRD.mdf
или другой каталог из localdb





Если я вас правильно понимаю, и вы просто хотите создать или изменить строку подключения в коде, вы можете просто использовать Класс SqlConnectionStringBuilder
Provides a simple way to create and manage the contents of connection strings used by the SqlConnection class.
Пример
String constr = (@"Data source=(localdb)\MSSQLLocalDB; initial catalog=DataHRD; integrated security=true;");
// Create a new SqlConnectionStringBuilder and
// initialize it with a few name/value pairs.
SqlConnectionStringBuilder builder =
new SqlConnectionStringBuilder(constr);
// Now that the connection string has been parsed,
// you can work with individual items.
builder["Data Source"] = @"C:\Users\SONY\Desktop\asda\asd\MainMenu\DataHRD.mdf"
// or anything else
builder.Password = "new@1Password";
builder.AsynchronousProcessing = true;
// You can refer to connection keys using strings,
// as well. When you use this technique (the default
// Item property in Visual Basic, or the indexer in C#),
// you can specify any synonym for the connection string key
// name.
builder["Server"] = ".";
builder["Connect Timeout"] = 1000;
builder["Trusted_Connection"] = true;
Отказ от ответственности, это всего лишь пример, вы должны изменить это в соответствии с вашими потребностями
@ Necrodor21Sa, если не удалось войти в систему, вам нужно будет проверить правильность строки подключения и ее работу
//first add your Database to SQL-SERVER
//then use this way
//if in Server use SSPI
string constr = (@"Data Source=.\MSSQLLocalDB;Initial Catalog=DataHRD;Integrated Security=SSPI");
как насчет неудачного входа в систему? Я использую Visual Studio 2017