Click here to Skip to main content
15,896,539 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Expert

I am working with a project in c# vs.net 2005 and sql express as backend. I have successfully completed the works. I want to connect my application and SQL Express on LAN. I have successfully connected the database one day before but because of some problem I have formatted the hard-disk on both client and server machines.

My application is throwing this error:
Create databse permission denied in database 'master'.
An attempt to attach an auto named database for file
C:\myDB.mdf failed.
a database with same name exist , or specified file cannot be opened, or is located on UNC share.

In this regard I have some questions.

1. Is there any way to create a login without using sql management studio. Using this query "CREATE LOGIN user WITH PASSWORD='pwd'"
It executes successfully but gave this error:
"Login failed for user user. the user is not associated with a trusted sql server connection"

2. If I login with Windows authentication then I receive this error:
Create database permission denied in database 'master'.
An attempt to attach an auto named database for file C:\myDB.mdf failed.
a database with same name exist , or specified file cannot be opened, or is located on UNC share.

What is the problem with my application?
thnx
Posted
Updated 7-Jul-11 1:02am
v2
Comments
wizardzz 6-Jul-11 12:40pm    
Not sure, but that sounds like a botched install. If there is no data, is reinstalling SQL an option?
Emrah Taylan 6-Jul-11 16:46pm    
Have u tried with 'sa' user?

1 solution

I think this should work,
1. execute the following statement
start>>Run>>CMD
"osql -S <SQL InstanceName> -E"

"alter login sa enable"
"go"

"alter login sa with password='pwd'"
"go"

2. check the file myDB.mdf in sqlserver installation path
stop the sqlserver services delete the myDB.mdf file and try again.
 
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