Click here to Skip to main content
15,911,531 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear frens,

I have this serious issue...

I need to host the site which is in asp.net c#. I somehow did uploaded the asp.net code files to the server but the database is not connected. When i ask the server providers, they informed that i can do that using localhost and they have provided me with username and password and the database name but how can i connect to that server where the database exist.

I seriously need some quick help !!!please reply asap
Posted
Comments
Joezer BH 5-Aug-13 5:29am    
Sorry mate, try to be more calm and provide the details explicitly.
i.e. try to explain in more details about the server, the SQL Server, it's location etc
Hemant Singh Rautela 5-Aug-13 5:38am    
So simple use below connection string with accurate parameter...
<add name="Connect" connectionstring="Data Source=serverip;Initial Catalog=databasename;user id=user; pwd=password" providername="System.Data.SqlClient"> </add>

Use the connection details they provides to form your connection string. It'll be somethign along the lines of:
@"Data Source=localhost\SQLEXPRESS;Initial Catalog=MyDB;User Id=xxxx;Password=xxxx;"
Or
@"Data Source=localhost\SQLSERVER;Initial Catalog=MyDB;User Id=xxxx;Password=xxxx;"
Put it in your web.config file, so you don't have you recompile each time if it's wrong...
 
Share this answer
 
You need to change your ConnectionString in Web config if you have any.

Then from code connect to the Database using the ConnectionString.

To know how to connect to Database - [MSDN] Connecting to Databases in ASP.NET[^].
To know more about ConnectionStrings - www.connectionstrings.com[^].

You will also find videos on Google on the same topic.
 
Share this answer
 
Comments
karkiB123 5-Aug-13 12:09pm    
Do I need to have the ip address of the database server where i am hosting my website and database??? I have been provided the databasename, username and password but will it be sufficient to know where my database is located ????

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900