0

I have build an MVC application and it is working very well. I have created a model in MVC project to access the database from local Microsoft SQL Server 2014 and the model is generated and working properly.

Now I have to host my project entire solution to the htdocs folder and uploaded my database as well. On hosting site all my stuff is working properly but the problem is my database is not working. I do not know how to configure it with my website.

I think there is a connection string problem in web.config file, due to which the connection is not established between connection string and the database.

 <connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.;Initial Catalog=StarBuy;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
<add name="StarBuyEntities1" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=StarBuy;user id=hidden;password=hidden;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>

Is there a method to import the database from the hosting website to local Microsoft SQL Server 2014, so that I can update the Model and update the new generated connection string in the web.config file?

Your thoughts will be very appreciated.

3
  • Add your webconfig connection string in the question Commented Oct 17, 2016 at 5:52
  • @JibinBalachandran: I have added my connection string . Commented Oct 17, 2016 at 6:24
  • Probably you need to include user id=hidden;password=hidden in DefaultConnection string. Ensure your DefaultConnection working properly then, include any exception if you have. Commented Oct 17, 2016 at 6:28

4 Answers 4

1

Use this connection strings.

<connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=.;Initial Catalog=StarBuy; user id=**;password=**;" providerName="System.Data.SqlClient" />
    <add name="StarBuyEntities1" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=StarBuy;user id=hidden;password=hidden;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />  
</connectionStrings>
Sign up to request clarification or add additional context in comments.

2 Comments

Error. An error occurred while processing your request.
Have you set <customErrors mode="Off" /> in web.config? Turn it on by <customErrors mode="On" />, then show the error message.
1

In Sql Server '.' is used to connect local. Now Your DB is in remote server.

So instead of . symbol use Server name

For example- server name is '192.168.1.1\SERVER02'

 <add name="DefaulConnection" connectionString="Data Source=192.168.1.1\SERVER02;Initial Catalog=DATABASE_NAME;Persist Security Info=true;User ID=USER_NAME;Password=PASSWORD" providerName="System.Data.SqlClient" />

Just try it will work.

Comments

0

Replace the source from . to the proper database server name. i.e youripaddress\SQL2014 or whatever is applicable in your case.

SQL

In my case I can access it as JIBIN/SQL2014 or ipaddress/SQL2014

<connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=JIBIN/SQL2014;Initial Catalog=StarBuy; user id=**;password=**;" providerName="System.Data.SqlClient" />
    <add name="StarBuyEntities1" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=JIBIN/SQL2014;initial catalog=StarBuy;user id=hidden;password=hidden;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />  
</connectionStrings>

Or else you can use your ip to access your database.

Comments

0

The dot (.) for server name can be used only when the Database server is the same as the application server. Use the correct database server name/ip instead of the (dot). You should find the connection string in the Hosting control panel if you are using any services like Plesk to host your application.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.