A couple of errors I am getting, both related to SQL Server, when trying to run an app on my local machine.. please help..! [closed]
I am in the following situation:
- I have been 开发者_JAVA百科requested to write an application for managing where we have customers - this must flag up when we try to add a customer too close to another one, so must be able to calculate distances based on post codes.
- I have chosen to use ASP.Net VB because I am fairly good at that and I like that the browser does all of the layout for me (using Java or C# would mean having to position each element individually).
- I have copied a few files from the company's website (which I also wrote) and modified them to account for the database structure we need for the new app.
- I have designed the database to account for the requirements of the new app.
- I have set up a website in IIS on port 81 through which to view the app.
Having done all this, I have been receiving various errors such as "Could not load type XXXX" (which at least means that the page is being detected since the type is specified at the top of the aspx page, but no more information is given about what the error is caused by).
The next error was "An attempt to attach an auto-named database for file App_Data/XYZ.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.". This error only occurs on the website when running from Visual Web Developer. It does not occur on the site I have set up in IIS on port 81.
Having got past the above error by using port 81, I am now getting another error - "CREATE DATABASE permission denied in database 'master'. An attempt to attach an auto-named database for file failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.". This has me completely stumped as I am not even trying to create this database. It is occurring when trying to execute the delete procedure (which currently does nothing). When executing the select procedure (SELECT * FROM Contacts) this error does not occur. I have not tried updating or inserting yet.
So to sum up, I am getting two problems - one when trying to run from VWD ("An attempt to attach an auto-named database for file App_Data/XYZ.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.") and one when trying to run from the site I set up in IIS on port 81 ("CREATE DATABASE permission denied in database 'master'. An attempt to attach an auto-named database for file failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."). I have no idea how to get past these and have never come across these before.
I need to be able to delete data as well, so I would REALLY appreciate it if someone could hint me in the right direction to solve this error. Many thanks in advance.
Regards,
Richard
Update:
Ok here is where I am now..
I have installed SQL Server 2008 - took me a while because it is like 300mb (including service pack) and I first installed 2005 then found the database was 2008.. :(). Any who, it is installed and I have attached the database successfully. However I am having trouble with the user accounts thing still. I have moved the application into C: so its now in C:/CustomerApp. This means I cannot encounter permission issues trying to access files in "My Documents" - one less issue to possibly have to deal with later.
I am now getting "Login failed for user 'Clarkey'. I also tried including the domain, but that didn't work either. The username and password in the connection string are correct (as in they are the username and password I used to login to my laptop half an hour ago). The rest of the connection string must also be correct since it would otherwise say it could not find the database instead of failed to login, would it not??
I have tried adding a user in SQL Server Management Studio, to no avail. I added a user called Clarkey2 and assigned it to db_owner, datareader and datawriter, but this still didn't work.
The main user, Clarkey, has db_owner only - this should be enough to be able to update, insert and delete data, right?
Can anyone guide me through how to do this? Its really doing my head in at the moment and I really would like to get this application completed for 2 weeks time..
Many thanks,
Richard
The problem here is that your application has a database XYZ.mdf
file in the solution. The application is attempting to attach that database on-the-fly to a SQL Server.
Suggest that you make a slight change here, and move that MDF into SQL Server itself. No need for the application to be auto-creating the database itself.
- Move that MDF file over to your SQL Server machine.
- Open SQL Server Management Studio, and Attach Database. Find the
.mdf
. - create a server login and database user as you require.
- modify your web.config file to use a connection string for your new database location. Create a new connection string from scratch.
精彩评论