1

private string conString = "Data Source=173.56.33.6;Database=musicapp;User ID=guest;Password=guest"; I was working on local database at that time my application was successfully interacting with mysql database.when put the database on server, my application still taking the old connection string and data is stored in local database and not on server. what is wrong?

2
  • Is it using the connection string from the web.config or app.config still ? if not, make sure you do a clean of your code before build, otherwise strange if you using conString for connections. Commented Jun 11, 2011 at 9:02
  • i m not able to see clean option in my visual studio 2008. what should i do? Commented Jun 11, 2011 at 9:06

4 Answers 4

3

I'd remove hard coded connection strings all together. There is a dedicated section of your config file for this very purpose:

<connectionStrings>
    <add name="MusicApp" connectionString="Data Source=173.56.33.6;Database=musicapp;User ID=guest;Password=guest;" />
</connectionStrings>

Which you can then read out:

string connection = ConfigurationManager.ConnectionStrings["MusicApp"].ConnectionString;
Sign up to request clarification or add additional context in comments.

Comments

0

I think your problem is that you have the connection string hard-coded in your code (as a private string that you show above). A much better way is to store it in the config file, use Settings in VS and select ConnectionString as type.

2 Comments

did this.even if i do not pass connection string it stores data and do not give me error.what's so wrong?
There probably is some default that it's using. Add some logging when you open the command so you can see what the string is and then figure out what it's read from.
0

Make sure whether you updated your connection string when you transfered your DB to server. In any case it is best to store connection string in web.config, so that you can modify it when ever your db is changed or transferred to another location. This change in connection string in your web.config wouldn't require you to rebuild your application. Although if your connection string is hard-coded in code, then you would require to rebuild your application when ever you change the connection string.

Comments

0

if Data Source=173.56.33.6; is the location of your server database try this instead Data Source=\173.56.33.6;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.