Click here to Skip to main content
11,705,453 members (30,626 online)
Rate this: bad
good
Please Sign up or sign in to vote.
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
katela718
Edited 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 = ; Password = ; 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
0 Sergey Alexandrovich Kryukov 525
1 OriginalGriff 244
2 CPallini 82
3 ppolymorphe 76
4 Inimicos 60
0 OriginalGriff 8,988
1 Sergey Alexandrovich Kryukov 8,272
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,606


Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2015
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