Click here to Skip to main content
13,090,299 members (91,073 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: , +
Hi guys,
I am not very good in ASP.Net, I developed a website with ASP.Net 2010, i used the default membership provider and it works very well on my Local PC with its defaults configuration and default database(AspNetSql.mdf).
My problem is I dont know how to change this defaults configuration to match my web hosting company configuration.
I created an sql database Through control panel of my website:
server: Enk-sql01.swh.mweb.co.za
Database : AspNetSql
username : User, I gave him all permission
Password:
and the web hosting company they gave me the name of the server: XX-sql01.xx.mweb.co.za and its SQL 2008 R2
Can somebody help me how to configure my website to work with these details?
Thanks
Posted 10-Jan-13 22:30pm
katela936
Updated 11-Jan-13 0:22am
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

So you just need to know how to build a connection string?

so it would be "Data Source = Enk-sql01.swh.mweb.co.za; User Id = <username you="" gave="">; Password = <password you="" gave="">; Initial Catalog = AspNetSql" would be your connection string

Also, http://www.connectionstrings.com/[^]

Example:

web.config file
<appsettings>
    <!-- [DATABSE SERVER SETTINGS}-->
    <add key="DB_Server" value="Enk-sql01.swh.mweb.co.za" />
    <add key="DB_User" value="Your Username" />
    <add key="DB_Pass" value="Your Password" />
    <add key="DB_Name" value="AspNetSql" />    
  </appsettings>

string ConnectionString = String.Format(@"Data Source = {0};User Id={1}; password={2}; Initial Catalog = {3};",
                            ConfigurationManager.AppSettings["DB_Server"],
                            ConfigurationManager.AppSettings["DB_User"],
                            ConfigurationManager.AppSettings["DB_Pass"],
                            ConfigurationManager.AppSettings["DB_Name"]);
 
string query = "your query here";
 
SqlConnection connection = new SqlConnection(ConnectionString);
connection.Open();
SqlCommand queryCMD = new SqlCommand(query, connection);
SqlDataReader queryReader = queryCMD.ExecuteReader();
while (queryReader.Read())
{
//do your work here
}
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Thanks a lot, it worked. I apreciate.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100