I have created a setup file for a WPF application with Database in MDF format and I'm trying to test the application and to connect it to the attached database, but I'm still getting this error :
Error on Connection settings System.Data.SqlClient.SqlException (0x80131904): Login failed for user 'admin'.
Error Number :18456,State :1,Class :14
And this my connection string :
Data Source=(localdb)\MSSQLLocalDB;AttachDbFileName=C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\database.mdf;User ID=admin;Password=test;
I'm using :
Update:
The answer suggested not working for me and I got this error :
Error on Connection settings System.Data.SqlClient.SqlException (0x80131904): An attempt to attach an auto-named database for file C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\database.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
The database is already attached :
User contributions licensed under CC BY-SA 3.0