locked
How connect C# to mysql directly? RRS feed

  • Question

  • Hi I have WordPress site with MQSQL as data base. I write One C# Program and I need connect to my database site for some send and receive data between site and user. I do not want Use rest API. I want Connect Directly to MySQL. (Honestly I do not understand how REST API Work)
    So how connect C# to MySQL directly?
    Wednesday, November 18, 2020 4:33 PM

All replies

  • Is your database accessible from outside the server?  In some cases, WordPress sites use a local database that can't be accessed from outside.

    MySQL does have a "Connector/.NET" which lets you access databases directly.  You'd need the server's IP address and your credentials.


    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Wednesday, November 18, 2020 7:23 PM
  • Thank you for answer and for now my site on localhost yet. But in few days my site and database get online and I should remote access for it.

    Wednesday, November 18, 2020 7:45 PM
  • Hi linksadi,

    Thank you for posting here.

    In my memory, it seems that some modifications to some of the MySQL configuration files and system tables are required to enable it to accept remote connections. In addition, the firewall may require some settings.

    But I haven't set it for a long time, so I'm not sure what to do.

    Try to post the question on the Mysql forum, they should be more familiar with it.

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best Regards,

    Timon


    "Visual c#" forum will be migrating to a new home on Microsoft Q&A ! We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A ! For more information, please refer to the sticky post.

    Thursday, November 19, 2020 2:11 AM
  • thanks for your response.

    (Honestly I Create the post with this text in WordPress forum and suggest me to use Rest API. but I can not Understand how to do it. So I decide Connect directly, But I know this makes it less secure than the API itself)

    Actually I have Online Downloadable file Store Created with Woocommerce and I have One C# Program for show the Content of product to User. I Want Connect the C# to WordPress. So User can login to their account and use files they buy it on my C# program.

    I Need coding this step in C# program:
    1. how can get the username and password of user and check if valid or not?
    2. how can get the name, nickname, email and some other the detail of user after they Successfully login to show that in labels in my program and use this in some other function (I Created before).
    3. I need Check witch product they Bought and the the expire date of the link too.
    4. finally get the links and file name of product they Bought and put this data in specials function (Also I created before too). so user can use my products.
    ________
    how can to do that step? I can not find the Proper training of Rest API and C# from beginning to expert and do not understand completely how this API worked.
    please help me.

    Thursday, November 19, 2020 5:55 AM
  • Hi linksadi,

    Many members here may not be familiar with the WordPress API. In this case, it is difficult for us to put forward any constructive comments. You may need to go to their development forum to ask for some help on their API.

    These requirements are basically a complete project. You can use Windows Forms or WPF to make such a project, but most of the content needs to be completed by yourself.

    You can post your questions here or Microsoft Q&A when you encounter specific problems, and we will try our best to help you solve these problems.

    Microsoft's documentation:

    Windows Forms documentation

    Windows Presentation Foundation (WPF) documentation

    An example of calling REST API in c#:

    How do I make calls to a REST API using C#?

    The development forum they provide:

    Developing with WordPress Forum

    API they provide:

    Common APIs Handbook

    Best Regards,

    Timon


    "Visual c#" forum will be migrating to a new home on Microsoft Q&A ! We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A ! For more information, please refer to the sticky post.

    Friday, November 20, 2020 5:56 AM
  • thanks for your response.

    (Honestly I Create the post with this text in WordPress forum and suggest me to use Rest API. but I can not Understand how to do it. So I decide Connect directly, But I know this makes it less secure than the API itself)

    Actually I have Online Downloadable file Store Created with Woocommerce and I have One C# Program for show the Content of product to User. I Want Connect the C# to WordPress. So User can login to their account and use files they buy it on my C# program.

    I Need coding this step in C# program:
    1. how can get the username and password of user and check if valid or not?
    2. how can get the name, nickname, email and some other the detail of user after they Successfully login to show that in labels in my program and use this in some other function (I Created before).
    3. I need Check witch product they Bought and the the expire date of the link too.
    4. finally get the links and file name of product they Bought and put this data in specials function (Also I created before too). so user can use my products.
    ________
    how can to do that step? I can not find the Proper training of Rest API and C# from beginning to expert and do not understand completely how this API worked.
    please help me.

    You can also try to Whats this video : How To Call An API in C# - Examples, Best Practices, ETC
    Also search for a Program to test API called Postman. In postman, u can export the web request to C#, and it will work just fine.

    I u join the video and that Postman funtionality, u can archive something.
    And if you want to access to MySQL Directly, install MySQL Workbench, talk with WordPress support. If u can access the Database from your local machine, just replicate those credentials to your C# code.

    Postman example:
    PS: My Postman interface has been modified, don't get lost in the default.
    Postman 1sPostman 2

    BP-LP 2016/2020 @ll rights reserved


    Monday, November 30, 2020 12:50 PM