ASP.NET MVC, Arvixe hosting web.config - asp.net

Good evening. I have a asp.net mvc3 web project, with sql server database 2012 and EF5. This site working perfectly on my local machine, but when I upload this to Arvixe web hosting and try to connect to pages which connect to database they print me an error:
Could not determine storage version; a valid storage connection or a version hint is required.
I'm try 2 different connection string, but everything without success:
<add name="PrimaryConnectionString"
providerName="System.Data.SqlClient"
connectionString="Data Source=camellia.arvixe.com;Initial Catalog=MyDatabaseName;Integrated Security=false;User ID=userLogin;Password=userPassword;"/>
<add name="SecondaryConnectionString"
connectionString="Data Source=localhost;Initial Catalog=myDatabaseName;Persist Security Info=true;User ID=userLogin;Password=userPassword;"
providerName="System.Data.SqlClient" />
and in code I'm use next part of code to connect to database:
My Context class
public UniversityContext(string connectionString)
{
Database.Connection.ConnectionString = connectionString;
}
Connect from context in project
private UniversityContext context = new UniversityContext(ConfigurationManager.ConnectionStrings[1].ConnectionString);
I'll try to connect to support, but the're didn't know why isn't working, and I'm very embarrased, Have anyone ideas, because I'm in a blind alley.

Don't you have the ip for the database that they gave you?
i use arvixe too, and my db conn in the web.config goes like this:
<connectionStrings>
<add name="MyDBConnectionString" connectionString="Data Source=65.98.21.152;Initial Catalog=mydatabase;User ID=mydatabaseLogin;Password=010101" providerName="System.Data.SqlClient"/>
</connectionStrings>
Hope this helps

Related

Unable to complete operation. The supplied SqlConnection does not specify an initial catalog or AttachDBFileName

I am trying to create an App Service web app in the Azure Portal and to connect the web app to my local on-premises SQL Server database using the new Hybrid Connection feature.
Created a simple ASP.NET application using Visual Studio 2015 and trying to connect to the SQL server Database which is on on-prem. And modified the connection String as follows
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=PRAVEEN,1433; User ID=sa; Password=my_password;"
providerName="System.Data.SqlClient" />
</connectionStrings>
When the application is started its running without any errors as shown in below screenshot1.
But when I try register (enter any record) it throws me with an error as specified in the below Screenshot3....
"https://azure.microsoft.com/en-us/documentation/articles/web-sites-hybrid-connection-connect-on-premises-sql-server/" - this is the documentation to which I'm referring to..
So, can anyone from the other end help me out please...
Microsoft SQL Server Management Studio screenshot....
Thank you..
#Praveen,
It is what it says - meaning Initial Catalog is missing in your connection string. It requires the Db name to connect to. You have the servername, SQLUserName, SQLPassword, but missing the DatabaseName it requires. Please change your connection string to include the the DbName as follows
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=YourServerName,1433;Database="YourDbName" UserID=YourId;Password=YourPswd;"
providerName="System.Data.SqlClient" />
</connectionStrings>
Look at this site to configure your connection string appropriately: http://www.connectionstrings.com/store-connection-string-in-webconfig/

Login failed. The login is from an untrusted domain

Introduction
I deployed my application Here on GearHost, everything went well. I clearly understand that its database access issue within application because some of the pages are accessible where no db connection is required like about-us.
Error : Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.
Connection String
<add name="IMConn" connectionString="Data Source=mssql3.gear.host;Initial Catalog=IMDb;Integrated Security=True;user id=****;password=******" providerName="System.Data.SqlClient" />
If someone have idea about that problem, please help.Thanks for your time.
Try IntegratedSecurity = false;
<add name="IMConn" connectionString="Data Source=mssql3.gear.host;Initial Catalog=IMDb;Integrated Security=False;user id=****;password=******" providerName="System.Data.SqlClient" />

how can i connect to database from IIS 5.1

When I want to connect to my site database via the local networkŘŚ This message will appear:
Cannot log in to my_server_name/AspNet
My connection string is:
<connectionStrings>
<add name="behbahan_cementConnectionString" connectionString="Data Source=MAYA-1307F9F334\SQLEXPRESS;Initial Catalog=behbahan_cement;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>`
I can't connect to the database?
I'd suggest you first try and establish whether you can connect to the database from outside the web application either via SQL Server Management Studio or by using a .UDL file. I've answered a question on testing a SQL server connection here.
Based on the results of these tests it may become apparent to you what the problem may be. In your case, you are using integrated security (which you would need to be on a domain to use over the network). If you are not on a domain, a username and password may need to be supplied.
Standard way to connect Database as;
<connectionStrings>
<add
name="NorthwindConnectionString"
connectionString="Data Source=serverName;Initial
Catalog=Northwind;Persist Security Info=True;User
ID=userName;Password=password"
providerName="System.Data.SqlClient"
/>
</connectionStrings>
What I can See here is you are messing ;
ID=userName;Password=password"
to connect the database in connectionString. Default username and password should be "root" unless you have changed it.
Try to connect with this detail.
Thanks,

Azure Web Sites connection string for EF not being picked up

I am deploying an ASP.NET web app to Azure Web Sites.
The site uses Entity Framework, and when I include the following in Web.config it runs fine:
<connectionStrings>
<add name="DataContext" connectionString="metadata=res://*/Models.WpsData.csdl|res://*/Models.WpsData.ssdl|res://*/Models.WpsData.msl;provider=System.Data.SqlClient;provider connection string="data source=XXXX;initial catalog=XXXX;persist security info=True;user id=XXXX;password=XXXX;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
However, if this connection string is removed and instead specified via the Azure Management Portal, an error occurs.
Name: DataContext
Value: metadata=res://*/Models.WpsData.csdl|res://*/Models.WpsData.ssdl|res://*/Models.WpsData.msl;provider=System.Data.SqlClient;provider connection string="data source=XXXX;initial catalog=XXXX;persist security info=True;user id=XXXX;password=XXXX;multipleactiveresultsets=True;application name=EntityFramework"
Type: Custom
This results in the error: No connection string named 'DataContext' could be found in the application config file.
See similar question here.
Try leaving the connection string in web.config with some value (either some test connection string, or some dummy value) e.g.
<connectionStrings>
<add name="DataContext" connectionString="dummy" providerName="System.Data.EntityClient" />
</connectionStrings>

database is not connecting in iis

I have two database.
<add name="OdonovanTestConnectionString" connectionString="Data Source=ODO-SRV004\;Initial Catalog=OdonovanTest;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="rackleyConnectionString1" connectionString="Data Source=ODO-SRV004\;Initial Catalog=rackleyTest;Integrated Security=true" providerName="System.Data.SqlClient" />
When I host my asp .net application in iis. The first database is connecting which is odonovantest.
But the database rackletTest is not connecting. Both database lies in same sql server.
Can any one give me solution?
you can call your connection string explicitly as code bellow:
string connectionString = SampleApplication.Properties.Settings.Default.rackleyConnectionString1;
using (SqlConnection con = new SqlConnection(connectionString))
{
con.Open();
// put code here
}
Make Sure you are using Windows Authentication or Sql Server Authentication.
In Web.config:
For Sql Server Authentication:
For Windows Authentication:
And then your have to define in codebehind also.

Resources