When i tried the above method i am getting the below error.
System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file OES_Data.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 52: Line 53: // Check if user already exists Line 54: var user = db.QuerySingle("SELECT email FROM tbl_UserProfile WHERE LOWER(email) = LOWER(@0)", email); Line 55: if (user == null) { Line 56: // Insert email into the profile table
Source File: c:\Documents and Settings\bz65\My Documents\My Web Sites\TestSite\Account\Register.cshtml Line:
54
Database.OpenConnectionString doesn't work, its a mistake in documentation.
use Database.OpenConnection and this works fine.
Very sorry to tell you this (especially given the number of points you have and the number of times you post the same helpful information) but according to my tests I have found the following results.
guru_sarkar
All-Star
22198 Points
3463 Posts
Use Database.Open for ConnectionString from web.config
Aug 12, 2010 06:12 PM|LINK
This is an FYI - I am not looking for a solution:
As mentioned in this tutorial (http://www.asp.net/webmatrix/tutorials/5-working-with-data), I tried using my own connectionstring from web.config.
I got this error: "Format of the initialization string does not conform to specification starting at index 0."
The tutorial suggests to use: Database.OpenConnectionString("SmallBakeryConnectionString") method
Instead you should use Database.Open("ConnectionStringName").
Ref: http://cytanium.com/forums/yaf_postsm18_Connection-string-problem.aspx
The API Document is missing Database.Open method and also Database.OpenConnectionString info needs to be modified.
tanatrajan
Participant
1784 Points
370 Posts
Re: Use Database.Open for ConnectionString from web.config
Aug 12, 2010 06:23 PM|LINK
Database.OpenConnectionString doesn't work, its a mistake in documentation.
use Database.OpenConnection and this works fine.
guru_sarkar
All-Star
22198 Points
3463 Posts
Re: Use Database.Open for ConnectionString from web.config
Aug 12, 2010 06:40 PM|LINK
That's true. I just posted it as FYI for others.
Aamir Hasan
Contributor
4270 Points
735 Posts
Re: Use Database.Open for ConnectionString from web.config
Aug 13, 2010 03:39 PM|LINK
http://aspxtutorial.com/post/2010/08/02/WebMatrix-Tutorial-Getting-Started.aspx
<div> <div>@{</div> <div></div> <div></div> <div> </div> <div></div><div></div><div>have you included connection string in your web config check it with same name
</div><div>
<connectionStrings>
<add name="SmallBakeryConnectionString"
connectionString="Data Source=|DataDirectory|\SmallBakery.sdf"/>
</connectionStrings>
</div> </div>webmatrix web.config connectionstring
Please Mark as Answered If its helpful you.
guru_sarkar
All-Star
22198 Points
3463 Posts
Re: Use Database.Open for ConnectionString from web.config
Aug 13, 2010 03:52 PM|LINK
Thanks Aamir Hasan but I am not looking for a solution.
rammohan555
Member
4 Points
6 Posts
Re: Use Database.Open for ConnectionString from web.config
Aug 16, 2010 03:58 PM|LINK
Hi,
When i tried the above method i am getting the below error.
System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file OES_Data.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Source Error:
Source File: c:\Documents and Settings\bz65\My Documents\My Web Sites\TestSite\Account\Register.cshtml Line: 54
Can you please help me on this?
guru_sarkar
All-Star
22198 Points
3463 Posts
Re: Use Database.Open for ConnectionString from web.config
Aug 16, 2010 04:33 PM|LINK
I am not sure but you might want to check if this discussion gives you some hint: http://forums.asp.net/p/1583385/3995929.aspx
buteo
Member
8 Points
6 Posts
Re: Use Database.Open for ConnectionString from web.config
Aug 31, 2010 10:25 AM|LINK
Very sorry to tell you this (especially given the number of points you have and the number of times you post the same helpful information) but according to my tests I have found the following results.
Database.OpenConnection does not exist.
Database.OpenConnectionString exists.
Database.Open exists.