Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i make a database using sql server 2008 then linked it with my c# interface , error meassge appear , here it 'Cannot open database Cofyshop.mdf requested by the login,the login failed with
login failed for user Beljika\beljk ' << this is error message and my connection string is
SQL
Server=(LOCAL);Database=Cofeshop.mdf;Trusted_Connection=True;


neeed help
Posted

you need to provide valid connection string
go to https://www.connectionstrings.com/sql-server-2008/[^] and check the connection string formats you can use.

note that Database property is for name of the database and it is not equal to database file name.

Quote:
The database name must be specified with the keyword 'database' (or one of its aliases) as in the following: "AttachDbFileName=|DataDirectory|\data\YourDB.mdf;integrated security=true;database=YourDatabase". An error will be generated if a log file exists in the same directory as the data file and the 'database' keyword is used when attaching the primary data file. In this case, remove the log file. Once the database is attached, a new log file will be automatically generated based on the physical path.
 
Share this answer
 
v3
Comments
beljk 21-Apr-14 11:50am    
the same error with all ,, but how can i find the username and password of database ??
DamithSL 21-Apr-14 12:00pm    
who created your database?
Your connection string is using TrustedConnection. This tells the SQL Server to use the account of the user running the code. It's telling you your account doesn't have permissions to the database you're trying to use.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900