Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9230461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:49:52+00:00 2026-06-18T05:49:52+00:00

I have added this connection information into both the Webconfig in the same file

  • 0

I have added this connection information into both the Webconfig in the same file level as the views folder, and the one in the views folder. It is also in the Web.Debug.config.

<connectionStrings>
<add name="MySqlServer"
connectionString="Datasource=foo.bar.net;Database=testasp;uid=Slendy;pwd=istall;"
    providerName="MySql.Data.MySqlClient"/>
 </connectionStrings>

And then I have this function I copy pasted from a how-to that crashes on adapter.Fill(ds) because of a MySqlException “Unable to connect to any of the specified MySQL hosts.” when I open /data/details/1

//
    // GET: /Data/Details
    public string Details()
    {
        // Get the MySQL connection string stored in the Web.config
        string cnnString = ConfigurationSettings.AppSettings["ConnectionString"];

        // Create a connection object and data adapter
        MySqlConnection cnx = new MySqlConnection(cnnString);
        MySqlDataAdapter adapter = new MySqlDataAdapter();

        // Create a SQL command object
        string cmdText = "select '3232' as ah;";
        MySqlCommand cmd = new MySqlCommand(cmdText, cnx);

        // Set the command type to StoredProcedure
        cmd.CommandType = CommandType.StoredProcedure;

        // Create and fill a DataSet
        DataSet ds = new DataSet();
        adapter.SelectCommand = cmd;
        adapter.Fill(ds);

        return "::::";
    }

My test sql table is on my website rather than localhost, and is as follows

a   b   c
1   2013-02-02 14:08:53 324
2   2013-02-02 14:08:53 342234

I had followed a guide here: http://dev.mysql.com/doc/refman/5.1/en/connector-net-tutorials-asp-roles.html but am not sure if I found the right file to edit. I also set permission on dreamhost for my computer to access it.

Update: cnnString is coming up NULL

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:49:53+00:00Added an answer on June 18, 2026 at 5:49 am

    Found out that ConfigurationSettings should be ConfigurationManager and set the line of code to be

    string cnnString = ConfigurationManager.ConnectionStrings["MySqlServer"].ToString(); 
    

    where “MySqlServer” matches the connectionstring name in the config file.

    This was a good help:
    C# Configuration Manager . ConnectionStrings

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added navigation controller into my appication in didFinishLaunchingWithOptions like this LoginViewController *mainView
I have one ViewController, in this i have added one Custom UIView named as
I have added this fix https://gist.github.com/2382288 for protect all fields against mass assignment in
I have added this rule in my web.config to redirect non www URLs to
I have added a UILabel to my view programmatically like this: myLabel = [[UILabel
I have added a ColorPropertyDescriptor to the Shapes example in GEF, however this displays
I have added some animation using jquery but it's not working: $('.test-container').click(function(){ $(this).css('background-color', 'rgb(119,
This didn't happen until I have added jQuery. function mfunc() {} mfunc.prototype.create = function(value)
I have added an extra field Specification in Catalog->Product->Data tab. This text is stored
I have been trying this for hours without success. http://replicaisland.googlecode.com/svn/trunk/ I have added the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.