I am working on the MVC storefront Rob Conery project and I lost my ASPNET.mdf database !
I would like to have the ASPNET.mdf database in my App_Data folder. I tried to include the db right clicking on it and including it in the project. But on the Server Exporer when I am tring to look at tables there are none.
Here is my Web.Config file :
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
<add name="CoderForTradersConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|CoderForTraders.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
What could be the problem ?
I had to include the aspnetdb.mdf from the VisualStudio tool prompt aspnet_regsql and add the database to my project.
Related
I've defined my connection string as ::
<add name="ammyGroupConnectionString" connectionString="Data Source=ammyGroup_Server;Initial Catalog=ammyGroup_Staging;Persist Security Info=True;User ID=sa;Password=ammyGroup;" providerName="System.Data.SqlClient"/>
<add name="ammyGroupConnectionString" connectionString="Data Source=ammyGroup_Server;Initial Catalog=ammyGroup_Staging;Persist Security Info=True;User ID=sa;Password=ammyGroup;" providerName="System.Data.SqlClient"/>
Now in the file there are tags,
<location allowOverride="true" inheritInChildApplications="true">
<appSettings>
<add key="DBSchema" value=/>
<add key="DBUserId" value=/>
<add key="DBPassword" value=/>
<add key="DBServerName" value=/>
<add key="DBName" value=/>
What does these keys are? What should be the value of these keys? Please explain.
I know that the keys
add key="DBUserId" and add key="DBPassword"
are for MS SQL SERVER user name and password but what when there is windows authentication only? Please explain.
I know for windows authentication we have to do ::
Trusted_Connection=Yes;Integrated Security=SSPI;
but what about appsetting values
<ConnectionStrings>
<add name="SiteSqlServer" connectionString="Data Source=DNN-CLONE-STAGE\SQL2008R2;Initial Catalog=latitudecg_dnn;Integrated Security=True" providerName="System.Data.SqlClient" />
</ConnectionStrings>
<appSettings>
<add key="SiteSqlServer" value="Data Source=DNN-CLONE-STAGE\SQL2008R2;Initial Catalog=latitudecg_dnn;Integrated Security=True" />
</appSettings>
This is my code to connect DB and dotnetnuke site(v7.4.0). I used this same connection when I upgraded from v6 to v7. But after upgradation, it shows me error Dotnetnuke Error ...Database Connection failed.. I don't know whats the error. I am running my site from IIS localhost like C:\inetpub\wwwroot\sitename ..
Can anyone tell me the solution?
Thanks in advance..
I'm creating a Site for ASP.NET, actually I made a EF model to create my DataBase, but this is just creating a SQL Express .mdf DB, I would like to know how I should change the Connection String to connect to an SQL Server DB.
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-WingtipToys;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="WingtipToys" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\wingtiptoys.mdf;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="ConnectionStringName"
providerName="System.Data.SqlClient"
connectionString="Data Source=ServerName;Initial Catalog=DatabaseName;Integrated Security=False;User Id=userid;Password=password;MultipleActiveResultSets=True" />
<configuration>
<connectionStrings>
<add name="MyCon" connectionString="Data Source=sys1-PC; Server=127.0.0.1; port=3306; Database=entmx001; Uid=root;Pwd=root_mysql; Convert Zero Datetime=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
this is my connection string in webconfig file.Now i want to connect my code to the database which is on other computer.what changes do i need to make here.or what else do i need to do..plzzhelp
<connectionStrings>
<add providerName="System.Data.SqlClient" name="MyCon" connectionString="Data Source=name_of_your_server;Initial Catalog=name_of_your_db; User Id=user_id;Password=password;" />
</connectionStrings>
The file neodb.mdf is in my App_Data folder and I can browse the database in the server explorer in visual studio, using built in SQLEXPRESS:
Currently trying to no avail:
<connectionStrings>
<add name="EFDbContext" connectionString=".\SQLExpress;AttachDbFilename=|DataDirectory|neodb.mdf; Database=neodb;Trusted_Connection=Yes;" providerName="System.Data.SqlClient"/>
</connectionStrings>
and
<connectionStrings>
<add name="EFDbContext" connectionString="Data Source=.SQLEXPRESS;Database=neodb.mdf;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
Also as I understand the *.mdf is an SQL server database file type and .dbo is owner of file when it's included in the initial catalog ? What's the initial catalog anywhere ?
If you have the *.mdf placed in App_Data folder, using this format works:
<connectionStrings>
<add name="ConnectionName"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|DatabaseName.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
There is a simple way to retrieve the connection string to each database.
Double click on "DataBase.mdf" file in Solution Explorer > right click on the "DataBase.mdf" file in Server Explorer > click "Properties" > Now you can see the connection string (under the "Connection" header) in the properties menu!
If you wanted the database to be created in your App_Data folder. You can use the following ConnectionString:
<connectionStrings>
<add name="ConnectionName" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|MyDatabase.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
Alternatively you can use:
<add name="ConnectionName" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=MyDatabase;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
Also you will see MyDatabase.mdf and .ldf database files are created in the C:\Users\YourUserName Folder.