Not able to uploade website on server - asp.net

I am try to uploading website.I don't know how configure database(web.config file) on uploading time.I am using Somee.com , anyone familiar with somee.com Or know how to configure database the please help me.
webconfig file code
<configuration>
<connectionStrings>
<add name="abc" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Jai-Ganesh\Documents\Visual Studio 2010\WebSites\testinmg\App_Data\Database.mdf;Integrated Security=True;User Instance=True"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<customErrors mode="RemoteOnly" ></customErrors>
</system.web>
</configuration>
Note: I don't know what is path of the dataSource in server.
Link of the page:
[http://www.imureditor.somee.com/add_value.aspx][1]

first you need to contact your hosting provider for connection string. They will give you the ip address (you can also the host name) which you can then configure it.
See the exmaple below;
<add name="connectStringName" connectionString="Data Source=somee.com;User ID=yourusernameforDB;password=yourpasswordforDB;Initial Catalog=yourDBName;" />
OR take a real example below;
<add name="KenSchoolConnectionString" connectionString="Password=1234;Data Source=192.168.1.1;Integrated Security=False;Initial Catalog=KenMISSchoolDB;User ID=sa" />
OR
Go to connectionstrings.com

Your connection string references your local SQL Server instance and tries to attach a local file; this connection string will need to be changed to reflect the setup on the server, so you'll need to specify the Data Source, Catalog, User ID and Password - Integrated Security won't work, and attaching *.mdf files from App_Data probably won't either.
Your service provider is responsible for giving you the credentials needed for this, we can't guess them.

Related

Website can't connect to database on smarterasp.net webserver - possible error in connection string

I am getting a problem when I try to connect from my website to my database on my webserver (smarterasp.net). Everything works fine on the local host, then I uploaded the site to smarterasp.net and created the database there, now the site can't connect to the database, here is what I have in my web.config:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="UsersConnectionString1" connectionString="Data Source=MYSQL5012.Smarterasp.net;Initial Catalog=db_9df63f_active;Uid=9df63f_active;Pwd=MYPASSWORD; "
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
</configuration>
Where password obviously includes my real password.
Here is what smarterasp.net provided as the connection string:
ASP.net "Server=MYSQL5012.Smarterasp.net;Database=db_9df63f_active;Uid=9df63f_active;Pwd=YOUR_DB_PASSWORD;"
Classic ASP "Driver={MySQL ODBC 5.1 Driver};Server=MYSQL5012.Smarterasp.net;Database=db_9df63f_active;Uid=9df63f_active;Password=YOUR_DB_PASSWORD;"
I also tried putting the connection string in the web.config file as connectionString= "Server=MYSQL5012.Smarterasp.net; Database=db_9df63f_active; Uid=9df63f_active; Pwd=MYPASSWORD;"
but this didn't work either.
Appreciate any help. Thanks!
It looks like smarterasp.net does not allow remote database connections if you dont have a premium account.
to solve that problem , after you publish your website, navigate to the file manager , on the root of your files on your website , there is a webconfig , edit it and modify the connection string there , replace it with the connection string given to you by the website database section.
on the websites webconfig file

how to find the sql connection string in asp.net

I added a new Sql Server Database to my project with the name: ShDB.mdf. It is located in a App_Data folder.
It contains a Table which has some columns. I could add some numbers to the table and then show them in a gridview on my localhost.
This is what I have in the web.config:
`<configuration>
<connectionStrings>
<add name="ShConnectionStr" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Javad\Desktop\Sharj\App_Data\ShDB.mdf;Integrated Security=True;User Instance=True"/>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ShDB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0"/>
</system.web>
`
Here is the vb.net code which I used:
Dim connectionString As String = ConfigurationManager.ConnectionStrings("ShConnectionStr").ConnectionString
And it works properly on the localhost test but when I published the website and uploaded the files on a web hosting service to test, I counter an error. How may I fix it? I think I should change my Data source path but I don't know how because its my first experience. Thanks to any help. you can see the error page here: http://www.kaj.somee.com/SL.aspx
Sql Server is either not installed or not running on the web host, or you don't have access to connect to it.
ASP.Net does not by itself know how to use your *.mdf database. It needs a running instance of Sql Server to talk to. It will tell Sql Server to load (attach) your database file, and then send queries to the Sql Server service for execution.
Do you mean you already uploaded the website to a web hosting service, but not the database?
If so, your application may not communicate directly with your database which is actually in your local machine.
You probably need to upload the database to a database hosting service as well (eg.SQL Azure, etc).
You may need to figure out the IP address/Server Name of your database hosting where you have uploaded. These information you can probably get in for the service provider. From there you should be able to connect to the database with the correct configuration.

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" />

Server Error in '/' Application

After searching my question's answer from stack overflow and other forums i am going to ask it myself, may be some one can guide me and make my way easy with asp.net programming.
I have a issue with saving values from my live website to database but all time i got error.
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off".
i have tried to view it by putting mode=off in my web.config but i am unable to view details of my error.
here is my web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
<authentication mode="None"/>
</system.web>
<location allowOverride="true">
<appSettings>
<add key="#" value="Password=#;Persist Security Info=True;User ID=#;Initial Catalog=#;Data Source=#"/>
</appSettings>
</location>
</configuration>
I have tested my database and my connection string on my live database using local solution of my project but when ever i tried to test it using my live server which is arvixe i am unable.
My fellow suggest me to use
<connectionStrings>
<add name="#" connectionString="Data Source=#;Initial Catalog=#;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
but it is not working with live server.
I am using app settings for connection string and i am confident with it because it is working fine with my local and live database.
I request to developers to test my online quran reading page and try to figure it out.
If you're using Sql Express, try this connection string
Data Source=.\SQLEXPRESS;DataBase=DBName;User ID=abcd;Password=xxxx;
As far as I know Integrated Security=True works with windows authentication. If you want to use this option then change the <authentication mode="None"/> to <authentication mode="Windows"/>.
If you are using Sql Server, may be try the following connection string
Standard Connection string
Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;
Trusted Connection
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;

web.config and membership

I have an Runtime error when I'm trying to perform login action or create user action on published website.
I have an ASPNETDB.MDF in appData folder, that created from ASP.NET Configuration.
I created new database in hosting, exported from ASPNETDB.MDF to a new database. I changed connection string.
Localy it work perfect, even with new connection string, but after i publish it i have an Runtime error.
I'm using asp login control and CreateUserWizard.
BTW, i've created some GridView and SqlDataSource to show all users, and it works.. But login and createWizard are not.
web.config
<configuration>
<connectionStrings>
<add name="ConnectionString" connectionString="Server=mssql3322.dotnet-host.com;Database=aspnetdb3;Uid=SomeUserNAme;Password=SomePassword;" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<roleManager enabled="true" />
<authentication mode="Forms" />
<compilation debug="false" targetFramework="4.0" />
</system.web>
</configuration>
BTW, i tryed to add membership provider to web.config and it didn't work even localy ))
UPD:
The error
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Well for starters you could add the following to your web.config:
<configuration>
<system.web>
<customErrors mode="off"></customErrors>
</system.web>
</configuration>
This should allow you to get a more detailed error message about what is wrong. See if that get's you started down the right path. It should at least provide more information about what might be wrong.
Update - try this in your web.config:
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Server=mssql3322.dotnet-host.com;Database=aspnetdb3;Uid=SomeUserNAme;Password=SomePassword;" providerName="System.Data.SqlClient"/>
<add name="ConnectionString" connectionString="Server=mssql3322.dotnet-host.com;Database=aspnetdb3;Uid=SomeUserNAme;Password=SomePassword;" providerName="System.Data.SqlClient"/>
</connectionStrings>
Update - That worked! Here is a short explanation why:
By default the ASP membership classes use the connection string LocalSqlServer. The reason the code worked on your local machine is because the connection LocalSqlServer is defined in a machine level config file to point to the local sql database. When you published it the SqlDataSource/GridView worked because it was pulling the connection named ConnectionString that pointed to the correct server. However ASP membership was still trying to connect to the LocalSqlServer connection. The above config just ignores the machine level LocalSqlServer connection and defines it's own (and it leaves the ConnectionString one in place so that the GridView continues to function).

Resources