Net Core 2.0 Mysql database to consume from WebAPI(newbie)





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















So I tried following this guide to link a MySQL database to my web application. https://www.c-sharpcorner.com/article/how-to-connect-mysql-with-asp-net-core/



Problem is I get these errors when debugging:



An unhandled exception occurred while processing the request.
ArgumentException: Option not supported.
Parameter name: port3306;database



MySql.Data.MySqlClient.MySqlBaseConnectionStringBuilder.GetOption(string key)

WebApplication2.Models.CountryContext.GetConnection() in CountryContext.cs

21. return new MySqlConnection(ConnectionString);

WebApplication2.Models.CountryContext.GetAllCountries() in CountryContext.cs

29. using (MySqlConnection conn = GetConnection())

WebApplication2.Controllers.CountriesController.Index() in CountriesController.cs

16. return View(context.GetAllCountries());


Also I can't figure out after approx 8h of searching how I can make this basic database work and consume data from a website.



I feel like i'm missing something very dumb...



And here's the git for the full application.
https://github.com/uzishan/TestWebAPI










share|improve this question























  • First, is that your real user and password you pushed to Github? Second, you need an = between port and 3306: ...;port=3306;... . Consider using MySqlConnectionStringBuilder to avoid syntax errors. Lastly, that is the default port anyway so you can omit it in this case.

    – Crowcoder
    Nov 25 '18 at 12:55













  • Some notes after reading your code: You're using the service locator (anti-)pattern (e.g. CountriesController), you may want to read docs.microsoft.com/en-us/aspnet/core/fundamentals/… . You're writing "low level" database access methods, you're aware of Entity Framework or Dapper?

    – Christoph Lütjen
    Nov 25 '18 at 13:10


















0















So I tried following this guide to link a MySQL database to my web application. https://www.c-sharpcorner.com/article/how-to-connect-mysql-with-asp-net-core/



Problem is I get these errors when debugging:



An unhandled exception occurred while processing the request.
ArgumentException: Option not supported.
Parameter name: port3306;database



MySql.Data.MySqlClient.MySqlBaseConnectionStringBuilder.GetOption(string key)

WebApplication2.Models.CountryContext.GetConnection() in CountryContext.cs

21. return new MySqlConnection(ConnectionString);

WebApplication2.Models.CountryContext.GetAllCountries() in CountryContext.cs

29. using (MySqlConnection conn = GetConnection())

WebApplication2.Controllers.CountriesController.Index() in CountriesController.cs

16. return View(context.GetAllCountries());


Also I can't figure out after approx 8h of searching how I can make this basic database work and consume data from a website.



I feel like i'm missing something very dumb...



And here's the git for the full application.
https://github.com/uzishan/TestWebAPI










share|improve this question























  • First, is that your real user and password you pushed to Github? Second, you need an = between port and 3306: ...;port=3306;... . Consider using MySqlConnectionStringBuilder to avoid syntax errors. Lastly, that is the default port anyway so you can omit it in this case.

    – Crowcoder
    Nov 25 '18 at 12:55













  • Some notes after reading your code: You're using the service locator (anti-)pattern (e.g. CountriesController), you may want to read docs.microsoft.com/en-us/aspnet/core/fundamentals/… . You're writing "low level" database access methods, you're aware of Entity Framework or Dapper?

    – Christoph Lütjen
    Nov 25 '18 at 13:10














0












0








0








So I tried following this guide to link a MySQL database to my web application. https://www.c-sharpcorner.com/article/how-to-connect-mysql-with-asp-net-core/



Problem is I get these errors when debugging:



An unhandled exception occurred while processing the request.
ArgumentException: Option not supported.
Parameter name: port3306;database



MySql.Data.MySqlClient.MySqlBaseConnectionStringBuilder.GetOption(string key)

WebApplication2.Models.CountryContext.GetConnection() in CountryContext.cs

21. return new MySqlConnection(ConnectionString);

WebApplication2.Models.CountryContext.GetAllCountries() in CountryContext.cs

29. using (MySqlConnection conn = GetConnection())

WebApplication2.Controllers.CountriesController.Index() in CountriesController.cs

16. return View(context.GetAllCountries());


Also I can't figure out after approx 8h of searching how I can make this basic database work and consume data from a website.



I feel like i'm missing something very dumb...



And here's the git for the full application.
https://github.com/uzishan/TestWebAPI










share|improve this question














So I tried following this guide to link a MySQL database to my web application. https://www.c-sharpcorner.com/article/how-to-connect-mysql-with-asp-net-core/



Problem is I get these errors when debugging:



An unhandled exception occurred while processing the request.
ArgumentException: Option not supported.
Parameter name: port3306;database



MySql.Data.MySqlClient.MySqlBaseConnectionStringBuilder.GetOption(string key)

WebApplication2.Models.CountryContext.GetConnection() in CountryContext.cs

21. return new MySqlConnection(ConnectionString);

WebApplication2.Models.CountryContext.GetAllCountries() in CountryContext.cs

29. using (MySqlConnection conn = GetConnection())

WebApplication2.Controllers.CountriesController.Index() in CountriesController.cs

16. return View(context.GetAllCountries());


Also I can't figure out after approx 8h of searching how I can make this basic database work and consume data from a website.



I feel like i'm missing something very dumb...



And here's the git for the full application.
https://github.com/uzishan/TestWebAPI







c# mysql






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 25 '18 at 10:40









wooshanwooshan

104




104













  • First, is that your real user and password you pushed to Github? Second, you need an = between port and 3306: ...;port=3306;... . Consider using MySqlConnectionStringBuilder to avoid syntax errors. Lastly, that is the default port anyway so you can omit it in this case.

    – Crowcoder
    Nov 25 '18 at 12:55













  • Some notes after reading your code: You're using the service locator (anti-)pattern (e.g. CountriesController), you may want to read docs.microsoft.com/en-us/aspnet/core/fundamentals/… . You're writing "low level" database access methods, you're aware of Entity Framework or Dapper?

    – Christoph Lütjen
    Nov 25 '18 at 13:10



















  • First, is that your real user and password you pushed to Github? Second, you need an = between port and 3306: ...;port=3306;... . Consider using MySqlConnectionStringBuilder to avoid syntax errors. Lastly, that is the default port anyway so you can omit it in this case.

    – Crowcoder
    Nov 25 '18 at 12:55













  • Some notes after reading your code: You're using the service locator (anti-)pattern (e.g. CountriesController), you may want to read docs.microsoft.com/en-us/aspnet/core/fundamentals/… . You're writing "low level" database access methods, you're aware of Entity Framework or Dapper?

    – Christoph Lütjen
    Nov 25 '18 at 13:10

















First, is that your real user and password you pushed to Github? Second, you need an = between port and 3306: ...;port=3306;... . Consider using MySqlConnectionStringBuilder to avoid syntax errors. Lastly, that is the default port anyway so you can omit it in this case.

– Crowcoder
Nov 25 '18 at 12:55







First, is that your real user and password you pushed to Github? Second, you need an = between port and 3306: ...;port=3306;... . Consider using MySqlConnectionStringBuilder to avoid syntax errors. Lastly, that is the default port anyway so you can omit it in this case.

– Crowcoder
Nov 25 '18 at 12:55















Some notes after reading your code: You're using the service locator (anti-)pattern (e.g. CountriesController), you may want to read docs.microsoft.com/en-us/aspnet/core/fundamentals/… . You're writing "low level" database access methods, you're aware of Entity Framework or Dapper?

– Christoph Lütjen
Nov 25 '18 at 13:10





Some notes after reading your code: You're using the service locator (anti-)pattern (e.g. CountriesController), you may want to read docs.microsoft.com/en-us/aspnet/core/fundamentals/… . You're writing "low level" database access methods, you're aware of Entity Framework or Dapper?

– Christoph Lütjen
Nov 25 '18 at 13:10












1 Answer
1






active

oldest

votes


















0














The error is in your connection string. It reads:



server=localhost;port3306;database=CountryDatabase;user=uzishan;password=mario1234


The second component should be:



port=3306;


Or you can drop that entirely, since it's the MySQL default.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53466662%2fnet-core-2-0-mysql-database-to-consume-from-webapinewbie%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    The error is in your connection string. It reads:



    server=localhost;port3306;database=CountryDatabase;user=uzishan;password=mario1234


    The second component should be:



    port=3306;


    Or you can drop that entirely, since it's the MySQL default.






    share|improve this answer




























      0














      The error is in your connection string. It reads:



      server=localhost;port3306;database=CountryDatabase;user=uzishan;password=mario1234


      The second component should be:



      port=3306;


      Or you can drop that entirely, since it's the MySQL default.






      share|improve this answer


























        0












        0








        0







        The error is in your connection string. It reads:



        server=localhost;port3306;database=CountryDatabase;user=uzishan;password=mario1234


        The second component should be:



        port=3306;


        Or you can drop that entirely, since it's the MySQL default.






        share|improve this answer













        The error is in your connection string. It reads:



        server=localhost;port3306;database=CountryDatabase;user=uzishan;password=mario1234


        The second component should be:



        port=3306;


        Or you can drop that entirely, since it's the MySQL default.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 25 '18 at 14:49









        Bradley GraingerBradley Grainger

        20k46688




        20k46688
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53466662%2fnet-core-2-0-mysql-database-to-consume-from-webapinewbie%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()