cant access the local database - asp.net

I host ASP.Net (MVC4) web site on Somee.com, but when i try to login to the web site its give an error please help me out to fix this matter thank you.
This is my "connectionStrings"
<connectionStrings>
<add name="GuestDBContext" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\HMS.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
This is the message that i get every time
My website -http://www.brownhotel.somee.com/

Related

ASP.NET VB change db connection on web forms framework

I have created an instance of ASP.NET Web Forms in my Microsoft Visual Studio. By default the program generates user login page and registration which are linked to the .mdb file.
I want to reconfigure the standard connection and link it to my instance of MSSQL 2012 SQLExpress server.
How can I do it?
Ok so I will give some direction and link you to a page.
First let me ask you this the connection you are using presently is it in a web.config file. If so this is where you will change the server/instance and database/catalog name.
Web.Config modification for SQL Server Instance
or this link
Web Config modification for SQL Express 2
So if you in the web.config file you should see something similar to this.
<ConnectionStrings>
<add name="" connectionString="Server=(localhost)\SqlExpress;Max Pool Size=300;Initial Catalog=database;User ID=username;Password=password;" providerName="System.Data.SqlClient"/>
</Connectionstrings>
or
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source= (LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\database.mdf;Initial Catalog=database;Integrated Security=True" providerName="System.Data.SqlClient" />
you need to change the follow:
Server or Data Source
and
Initial Catalog or AttachDbFilename
Now your credentials you may use any username and password that has access to the sql server express instance.
I hope this helps.

ASP.NET MVC 4 application database connection issue after session timeout

I have an MVC 4 website using .NET framework 4.5 that works fine at first. It allows me to login and go about my business adding, deleteing and editing records. As such, it is obviously initially connecting to the database without a probelm. However, if I leave it inactive for a while and come back at a later time, and then click a link to a page that shows data from my database, I get the following error:
The SSE Provider did not find the database file specified in the connection string. At the configured trust level (below High trust level), the SSE provider cannot automatically create the database file.
The website works fine on my localhost, but not when I host it online. I use shared hosting for this. I've done extensive searching online and found lots of people getting the same error, but they don't seem to have a website that works initially and then suddenly stops working. The solutions I've found online say something along the lines of:
add these two lines to your web.config file
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=p3swhsql-v15.shr.phx3.secureserver.net; Initial Catalog=DatabaseName; User ID=****; Password='****';"/>
by default the .net site is trying to find your database in the local filesystem in this case would be the app_data subfolder under the wwwroot directory. simply removing the connectionstring and replacing it with the database connection solves the issue. My example utilizes an SQL db on godaddy's server. however i'm sure you can replace the connection string with the appropriate string for your connection. good luck and i hope this helps anyone that may be having this issue
What my program seems to be doing is using the online database when I first login, and then reverting to trying to use the database in the local filesystem once the session timesout. This is very frustrating. My web.config file looks as follows:
<connectionStrings>
<remove name="DefaultConnection"/>
<add name="DefaultConnection" connectionString="Data Source=winsqls01.cpt.wa.co.za;Initial Catalog=SportFantasySA;Persist Security Info=True;User ID=*****;Password=*****" providerName="System.Data.SqlClient"/>
</connectionStrings>
Please help. I'm desperate to get this working. I understand that it can't create the sql express database in the hosting space, that's why I'm using the connection string for the database on my hosting company's server.
If you have hosted it on Godaddy go for the connection string as
<providers>
<remove name="AspNetSqlMembershipProvider" />
<add name="AspNetSqlMembershipProvider" connectionStringName="LocalSqlServer"
..other attributes here... /></providers>
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString="Data Source=xxxx; Initial Catalog=xxx; User ID=xxx; Password=xxx;"
providerName="System.Data.SqlClient" />

Deployment of SQL Server Express database fails

I have to deploy ASP.Net application with remote database connection in IIS server.
Deployment has worked fine without database. And I was able to run that application on the IIS server.
Coming to the application with remote database I have given the connection string in C# code. And it is connected.
My web.config has thsi connection string :
<configuration>
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
I have replaced that with my database connection credentials as follows:
<configuration>
<connectionStrings>
<add name="ApplicationServices"
connectionString="Data Source=RemoteHost,1433;Initial Catalog=DBNAME;user Id=MyUserId;Password=MyPassword"
providerName="System.Data.SqlClient" />
</connectionStrings>
In Package/Publish options I have selected (Import from web.config) and deployed that. Then I got the following error:
Web deployment task failed.(Object of type 'dbFullSql' and path 'Data
"Data Source=RemoteHost,1433;Initial Catalog=DBNAME;user
Id=MyUserId;Password=MyPassword" cannot be created.)
Object of type 'dbFullSql' and path "Data Source=RemoteHost,1433;Initial Catalog=DBNAME;user
Id=MyUserId;Password=MyPassword" cannot be created.
The source is invalid.
Script failed for Database 'DBNAME'.
Script failed for Database 'DBNAME'.
Index was outside the bounds of the array.
I am new to ASP.Net. Anybody please help me.
Thank you in advance
I think you didn't configure Web deployment package correct you can do that right Click on Project ,Select Properties and go to package/Publish SQL
I have add link for Walkthrough: Deploying a Web Application Project Using a Web Deployment Package (Part 1 of 4) for VS2010
http://msdn.microsoft.com/en-us/library/dd483479(v=vs.100).aspx

User in Web Site Administration Tool on IIS

I'm new in ASP and IIS and I trying to solve this problem for 2 days but still can't get it.at 1st, I created a ASP login page and the user information store in Web Site Administration Tool (VS2008 Project>ASP.NET Configuration) It works fine as I can log in to my aspx page when I debug it.
Next, I turn on the window feature (IIS under item World Wide Web Services >> Application Development Features all are selected except CGI)
Then, I publish my login page and go to C:\inetpub\wwwroot\web.config add few lines
<connectionStrings>
<add name="connect" connectionString="Data Source=USER-PC\SQLEXPRESS;Initial Catalog=school;Persist Security Info=True;User ID=sa;Password=password" providerName="System.Data.SqlClient" />
<add connectionString="data source=.\SQLEXPRESS;IntegratedSecurity=True;AttachDBFilename=|DataDirectory|ASPNETDB.MDF;User Instance=true" name="ConnectionString" providerName="System.Data.SqlClient" />
<add name="ptiConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|pti.mdf;IntegratedSecurity=True;User Instance=True" providerName="System.Data.SqlClient" />
</connectionStrings>
Next, I open up IIS Manager enable ASP.NET Impersonation and i try to browse to localhost and I still unable to access to my login page
I also enable Form Authentication but still the same , can't login. Can Anyone help me ??
Did you install IIS after you installed ASP.NET? If so, you'll need to register ASP.NET with IIS - see my answer here: Hosting ASP.Net MVC 4 SPA web Application in IIS

Godaddy ASP.NET membership database woes

I purchased a Windows shared hosting account on godaddy that came with 2 MSSQL databases. I setup one to hold my site data and the other installed aspnet membership schema to store site members. The site works perfectly even displaying data from the 1st database. However when I try to login or register I get this nasty error
Exception Details:
System.Configuration.Provider.ProviderException:
The SSE Provider did not find the
database file specified in the
connection string. At the configured
trust level (below High trust level),
the SSE provider can not automatically
create the database file.
Ive gone through my web.config and there's nothing wrong with my 2 connection strings. It seems godaddy has a problem with using 2 mssql databases simultaneously when 1 is for membership.
Does anyone know a solution or a workaround?
I hope my experience benefits every one. Basically if you want to avoid aspnet membership problems on godaddy always use "LocalSqlServer" as the connectionstring. i.e
<providers>
<remove name="AspNetSqlMembershipProvider" />
<add name="AspNetSqlMembershipProvider" connectionStringName="LocalSqlServer"
..other attributes here... />
</providers>
Then create the "LocalSqlServer" connectionString...remember to remove it first
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString="Data Source=xxxx; Initial Catalog=xxx; User ID=xxx; Password=xxx;"
providerName="System.Data.SqlClient" />
</connectionStrings>
I ran into same problem and am using MVC3. Above solution works but with some other changes in MVC3. It took me long time to figure it out so if anybody has similar issue in MVC3 it might help them:
Search for "connectionStringName" in web.config and replace the name with connectionStringName="LocalSqlServer"
Also under connectionstrings make sure
-To add (As this is important for all who are using shared hosting it will replace machine.config LocalSqlServer connectionstring with yours.)
-Keep your current connectionstring (In my case it is FilmiDb, this is required for you to connect to the database in EF model. Without this you will get errors.)
<connectionStrings>
<remove name ="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Initial Catalog=SofilmiDb;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
<add name="FilmiDb" connectionString="Data Source=.\SQLExpress;Initial Catalog=FilmiDb;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
</connectionStrings>

Resources