Please, Please Help!

I have been trying to figure this out for weeks now and I dont know what is going on. I am trying to insert a row into a database and for some reason it gives me this error. I really need help on this, I have been trying to figure this out for SO long and I can't find anything anywhere.

 

 

Unable to open the physical file "C:\ASP.NET\App_Data\dbInfo.mdf". Operating system error 5: "5(Access is denied.)".
An attempt to attach an auto-named database for file C:\ASP.NET\App_Data\dbInfo.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Unable to open the physical file "C:\ASP.NET\App_Data\dbInfo.mdf". Operating system error 5: "5(Access is denied.)".
An attempt to attach an auto-named database for file C:\ASP.NET\App_Data\dbInfo.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

Source Error:

Line 25:             if (txtSubject.Text != "" && txtDescription.Text != "") {
Line 26:                 // Insert into DB
Line 27:                 SqlDataSource_dbInfo.Insert();
Line 28: 
Line 29:                 // Hide Comment Form Panel

Source File: c:\ASP.NET\defaultContact.aspx.cs    Line: 27

Stack Trace:

0
JEREMER
6/26/2008 8:18:56 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

14 Replies
1016 Views

Similar Articles

[PageSpeed] 40

Erm...try putting it in another drive (D:). Vista is very strict about mucking about the C: driver. Otherwise, give the Network Service account write permissions to C: (not a very good idea).

0
HeartattacK
6/26/2008 8:57:17 PM

I'm actually using XP, I have this working at home so I thought it was an issue with having to Detach from the database because that's what I have to do at home to get it to work but I can't seem to do that.

Is there something wrong with my connection string?

Is it because I'm using Visual Studio 2008 Express?

...I'm just so confused because I can't figure out what is causing the problem.

0
JEREMER
6/26/2008 9:27:30 PM

See if the connection is open in Server Explorer or SQL Server Management Studio. If so, close it.

0
HeartattacK
6/26/2008 9:35:14 PM

 hi,

 Did you check your connection string? Maybe you can post it here so we can look at it also.

 

thanks,
 


Bryian Tan
MCP, MCAD
0
BryianTan
6/26/2008 9:43:15 PM

Sorry forgot that, here is my connection string. I have tried to change my connection string more times than I can count now finding different information on different websites and I just can't figure out what I'm doing wrong. If someone could help me figure out why I'm getting this error I would greatly appreciate it.

<connectionStrings>
    <!--
Connection for SQL 2005 Express -->
    <
add name="connectionString_dbInfo" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|\dbInfo.mdf"
   
providerName="System.Data.SqlClient"/>
    <
remove name="LocalSqlServer"/>
    <!--
Connection for SQL 2005 Express -->
    <
add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|\dbInfo.mdf" 
    providerName
="System.Data.SqlClient"/>
</
connectionStrings>

0
JEREMER
6/26/2008 10:18:02 PM

hi,

try this and see if it help http://weblogs.asp.net/bsimser/archive/2005/11/20/431029.aspx

or try set

Integrated Security=SSPI;


Bryian Tan
MCP, MCAD
0
BryianTan
6/27/2008 12:20:02 AM
JEREME, I had this and similar issue before on Vista. If I run Visual studio or express as administrator, it solves the problem. This I believe is a Vista security issue. Hope this helps ya.
0
hunzonian
6/27/2008 12:57:37 AM

I also encounter the same problem with you. What i did is that, I enabled sharing folder to network and allow network to change my file.

 

See other ASP.net tutorials

http://enter101.blogspot.com/ 


Everything you need to know about your PC and a collection of free asp.net, photoshop, javascript and sql tutorials for beginners and advance user.

enter101.blogspot.com
enter111.blogspot.com

0
eric_estrad
6/27/2008 1:28:21 AM

Unfortunately none of these things seem to solve my issue. I am using SQL Server 2005 Express, which to my understanding will have a different connection string than just SS2005. It seems that my connection string is incorrect from everything I've read but I just can't find anything that shows me how to configure my connectionString. Does anyone know if this is correct or not? If it is i can start looking somewhere else for the problem.

<connectionStrings>
    <!--
Connection for SQL 2005 Express -->
    <
add name="connectionString_dbInfo" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|\dbInfo.mdf"
   
providerName="System.Data.SqlClient"/>
    <
remove name="LocalSqlServer"/>
    <!--
Connection for SQL 2005 Express -->
    <
add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|\dbInfo.mdf" 
    providerName
="System.Data.SqlClient"/>
</
connectionStrings>

0
JEREMER
6/27/2008 3:01:20 PM

 Hi,

Do you have SQL Management Studio installed - check it using this. I am pretty sure that the database is already attached to the server instance, so when you try to add it again you are getting this error. You can either detach the database from the SQL instance in SQL Manager or change your connection string to Data Source=.\SQLExpress;Integrated Security=True;Initial Catalog=DATABASE NAME IN SQL;


I hope this helps, if it answers your question, don't forget to mark it as such for those who come afterwards.

Regards,

Gareth Chidgey
Managing Director
PushInternet Ltd
0
chidge
6/27/2008 3:10:21 PM

Sorry for my ignorance but what do you mean by "DATABASE NAME IN SQL;"? This is what my connection string looks like now.

<connectionStrings>
<!--
Connection for SQL 2005 Express -->
<
add name="connectionString_dbInfo" connectionString="Data Source=.\SQLExpress;Integrated Security=True;Initial Catalog=|DataDirectory|\dbInfo.mdf;" providerName="System.Data.SqlClient"/>
<
remove name="LocalSqlServer"/>
<!--
Connection for SQL 2005 Express -->
<
add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;Initial Catalog=|DataDirectory|\dbInfo.mdf;" providerName="System.Data.SqlClient"/>
</
connectionStrings>

...and this is what my sqlDataSource looks like. Maybe this is the issue?

<asp:SqlDataSource ID="SqlDataSource_dbInfo" runat="server"
ConnectionString="<%$ ConnectionStrings:SqlDataSource_dbInfo %>"
SelectCommand="SELECT [subject], [description] FROM [tbContact]"
InsertCommand="INSERT INTO tbContact (subject,description) VALUES (@parSubject,@parDescrip)">
<insertparameters>
    <asp:ControlParameter Name="parSubject" ControlID="txtSubject" PropertyName="Text" Type="string" />
    <asp:ControlParameter Name="parDescrip" ControlID="txtDescription" PropertyName="Text" Type="string" />
</insertparameters>
</asp:SqlDataSource>

0
JEREMER
6/27/2008 3:49:21 PM

 He means the name of the database. So it'd be something like this ";Initial Catalog=Northwind;"


"Hokey religions and ancient weapons are no match for a good blaster at your side."
0
DarthSwian
6/27/2008 5:35:14 PM

Hi,

Yes exactly that, the database MUST be already attached to the SQL instance, that is the only scenario that I can think of for that message. The connection string that you are using is temporarily attach a database file to a server instance, the string i specified is to connect to a database which is already attached on a permanent basis. If you are still stuck the best site for connection strings is connectionstrings.com


I hope this helps, if it answers your question, don't forget to mark it as such for those who come afterwards.

Regards,

Gareth Chidgey
Managing Director
PushInternet Ltd
0
chidge
6/27/2008 6:15:12 PM

Following are the different Connection string for SQL Express 

Attach a database file on connect to a local SQL Server Express instance  
Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
 
Why is the Database parameter needed? If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection. 

  

Attach a database file, located in the data directory, on connect to a local SQL Server Express instance
Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;

 
Why is the Database parameter needed? If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection. 
 

Using an User Instance on a local SQL Server Express instance
The User Instance functionality creates a new SQL Server instance on the fly during connect. This works only on a local SQL Server 2005 instance and only when connecting using windows authentication over local named pipes. The purpose is to be able to create a full rights SQL Server instance to a user with limited administrative rights on the computer.  

Data Source=.\SQLExpress;Integrated Security=true;AttachDbFilename=|DataDirectory|\mydb.mdf;User Instance=true;
 
To use the User Instance functionality you need to enable it on the SQL Server. This is done by executing the following command: sp_configure 'user instances enabled', '1'. To disable the functionality execute sp_configure 'user instances enabled', '0'. 
 

Hope this helps


BN
--------------------------------------
Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question.
0
bn222
6/27/2008 6:54:21 PM
Reply:

Similar Artilces:

Please! Please! Please! Please! Help
I am very new to the Linux/Oracle/Perl world coming from a many many years of a Windows environment. I have self learned everything I know about this new environment. So far I have successfully installed Redhat 9 in an Intel box and have gotten Oracle 9I running correctly. I can run scripts via sqlplus, sqlldr etc. Perl (I think ver. 5.8.0) is running on the box and I can create and run scripts that do other processes but I have had no success in getting Perl to connect to the Oracle database to generate some reports. With my experience using MS-SQL there is no major issues w...

Please Please Please HELP!!!
I have posted this many times to no avail. I managed to publish the site somwhere despite being an intranet. I have published the site just in case I was not clear in explaining the prblem that I was having. Go to http://www.undg.ks.undp.org/test/login.aspx and login with userid: test password: test Click on 'search for cases' and then click on the search button (the dates are inserted automatically). Click on the paging and try to go to page 12,13,14,15 - any page really above page 11. Can you see what is happening? Below is the code that I am using. Please tell me wha...

Please Please Please help
I am trying to populate a second dropdownlist from the first. both dropdownlists are displayed inside the datagrid. I can populate the first one easily but my onselectedindexchanged event states: Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 195...

Please Please Please help me out...
hello, our netware 6.0 file server can'nt connect the internet, we have a proxyserver with netware 6.0 and BM 3.8. can somebody please help me out i'm a newbie. hello, our netware 6.0 file server can'nt connect the internet, we have a proxyserver with netware 6.0 and BM 3.8. can somebody please help me out i'm a newbie. the file server ip is 192.20.71.1 the proxy ip is 192.20.71.252 akula_26@hotmail.com wrote: > our netware 6.0 file server can'nt connect the internet, we have a > proxyserver with netware 6.0 and BM 3.8. can somebody please hel...

Please help, please, please
This is driving me crazy, I cannot find what is wrong with this thing. I have a custom module and after post back none of the following are processed : user, login, visibility, title, solpartmenu. None of it gets processed. Please help meYou died at the very end of your life Are you saying a skin, or a custom module. With custom modules you should not be dealing with tokens, I don't think they have anything to do with it. What module are you working with? No I am not using tokens, container skin is Classic skin that comes with DNN. I am talking about custom module. It has a text box a...

PLEASE PLEASE PLEASE
Name: Nick Crain Email: n.crain_at_rogers.com Product: Firefox Summary: PLEASE PLEASE PLEASE Comments: Can you please include a rss feed indicator thing like IE 7 has. You know where every time you visit a page that has an rss feed available it beeps and then you can subscribe to it? That is such a handy feature. It's just too bad it's on a damn microsux product. please put it in firefox. Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7 Nick Crain wrote: > Name: Nick Crain > Email: n.crain_at_r...

please please please
Name: Product: Firefox Summary: please please please Comments: could you please resolve this crashing. the browsers crashes so often... I'm watching streaming video and it crashes in the middle of it... which costs me. I don't want to exceed me bandwith with friggin rogers. they're a pain. Browser Details: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you mus...

Please please please
Folks, Please can we stop the petty bickering about banning or not banning............... The points have been made and in my opinion this is not the place to carry on with it. Once again - PLEASE! Regards Ian _____________________________________ Ian Sargent Education & Training Consulting Services Ltd Tel/Fax: 01344 644579 Mobile: 07970 847197 email: ians@etcs.co.uk www: http://www.etcs.co.uk _____________________________________ "Ian Sargent" <ians@nospam_etcs.co.uk> wrote in news:af7d6c$2da6$1 @news.grc.com: > Please can we st...

Please, please, please ....
Name: Dean Talboys Email: deanatlouistalboysdotcom Product: Firefox Summary: Please, please, please .... Comments: Could you include a button on Firefox to register the currently viewed site as Firefox "Unfriendly"? I'm a developer of sophisticated Internet applications (check out http://www.psychl.com/ONE/cyclex.asp to see how much abuse a browser can take) and I always spend time to ensure my sites are IE and Firefox compatible. But I'm really frustrated at the number of sites that aren't Firefox compatible. You know, you get to the last screen of ...

Please Please Please
I have only been asking for 4 years but PLEASE include a setting at the accounts level that sets the default compose to plain text if the account of type NEWS. Its a PITA to have to recall or remember to change my compose to plain text manually! Andre, It appears that in the past few days you have not received a response to your posting. That concerns us, and has triggered this automated reply. Has your problem been resolved? If not, you might try one of the following options: - Do a search of our knowledgebase at http://support.novell.com/search/kb_index.jsp - Check a...

LDAP Request Help
My head is about to fly off my neck and shoot through the ceiling! Ive been trying to make the following code work for weeks, and I cannot figure it out. The code is located at this website: http://v5.beta.docutek.com/eres/custom/fresnoLDAP.aspx. Everytime I try to run this sub I get the following error: "Unknown error (0x80005000) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.InteropServic...

Please help...please
Name: jOHN MILEQUE Email: kingofallkings08athotmaildotcom Product: Firefox Summary: Please help...please Comments: Heloo...how do i remove firefox as my default browser...i dont want to make it my default browser...i want internet explorer to be my default browser but i need help on that....fast as possible.. Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4 ...

Please please help...
can someone please help me to link the asp to my database and return specific results in html. I'm really stuck and I have to hand the assignment in today at 12. I'm really stuck. asp.zip > I'm really stuck. You sure are — you're not even on the right forums. ASP developers talk on the ASP Messageboard.Alister What you want to do in this problem. Enter the data from user. Then insert into table. And finally show the result. Clear the problem.My Blog: DotNetError@BhatiaWorldDont forget to click "Mark as Answer" on the post that helped you.This credits tha...

Please, please help.
My web page would not show, so I wrote and uploaded a small config file. The index.aspx file will show now. Now I have a problem that is horrible. When My website is displayed, it is really, really slow to load. All images are displayed one after another it appears. For example, my toolbar buttons will display, coming in about once every second. Then other images succesively come in slow. It looks so bad. Imagine 1996 with a slow pc accesing the web. Just like that. What can I do? Is there a way to cache everything in a page before it is actually displayed to the screen. I am rea...

Web resources about - Please, Please Help! - asp.net.getting-started

PM Modi calls for India-China partnership to fight global terrorism
The threat of international terrorism and the global economic slowdown dominated talks between Prime Minister Narendra Modi and his Chinese counterpart ...

Fox’s Greg Gutfeld, Thinks He Knows More About Syrian Refugees Than Obama – Because Benghazi!
Only on Fox News would a chickenhawk like Greg Gutfeld, who has not a single credential in national security, smear a twice-elected president ...

Donald Trump: No Plans For Muslim Registry, Says Words Were Misconstrued
A request for a way to track Muslims in the United States may seem ideal to Republican presidential candidate Donald Trump, but his idea is meeting ...

Zuckerberg to take paternity leave
FACEBOOK boss Mark Zuckerberg will take two months of paternity leave after his daughter's birth, a strong statement from one of the busiest ...

Tesla Model S: Recalls for 90,000 cars over seatbelt fault
ELECTRIC car company Tesla has issued a worldwide voluntary recall to every single Model S on the road, around 90,000 in total.

Saturday's Best Deals: Early Black Friday Sales, Your Favorite Headphones, and More
Here are the best of today’s deals. Get every great deal every day on Kinja Deals , follow us on Facebook and Twitter to never miss a deal, join ...

Kylie Jenner Hangs Out with Justin Bieber After Tyga Split
Kylie Jenner steps out of The Nice Guy lounge with some friends on Friday night (November 20) in West Hollywood, Calif. The 18-year-old reality ...

Peter Gold Shooting Video: Medical Student Shot In Stomach, Nearly Executed While Saving Woman Being ...
Peter Gold was shot and nearly executed after the medical student stopped his car to save a woman from being mugged and abducted. Video of the ...

Navy Aircraft Carrier Makes Awesome Star Wars: The Force Awakens Trailer Spoof!
The force is strong with the crew of the super carrier USS Dwight D. Eisenhower (CVN-69) and Carrier Air Wing Seven, as you can tell by the fantastic ...

Two Australian tourists, four Britons killed in helicopter crash in New Zealand, police believe
Two Australian and four British tourists are killed in a helicopter crash in Fox Glacier on the west coast of New Zealand's South Island, New ...

Resources last updated: 11/21/2015 5:33:27 PM