i have an free web host on aspspider.com and i have made an page with asp.net and a sql database under root\Database\db1.mdf. the code on my page is in c#.

i have an code for db acces but it doesent work

string connectString = @"Data Source=~\root\Database ;Initial Catalog=DB1";
            System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(connectString);

what is wrong with this code please help

6 Years
Discussion Span
Last Post by sujimon

aspspider are the one who can help you on this. i used to host at Somee.com for free , but they mysteriously deleted my database ,so free web hosting for a database is not safe. but you need ask them the connection string.


I think the connectionString format should be of the following:-

Data Source=Servername;Initial Catalog=Db1;Persist Security Info=true;User ID=myuserid;Password=123;


Data Source=Servername;Initial Catalog=Db1;Persist Security Info=true;Integrated Security=true;

NOTE:- for remote connections the Servername is the IP-Addr of the database server you can get this from aspspider

This new connection string should work. You may have to contact aspspider for the Servername attribute as well as the login ID and password.

In case, you have yourself created a new database using the Control Panel you will have the credentials. (SQL-Server default username is 'sa' and password empty)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.