Announcement

Collapse
No announcement yet.

MySQL integration in UE4 with C++

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    MySQL integration in UE4 with C++

    Hi everybody.

    I need a help with MySQL in the UE4.
    I managed to make a program in C ++ to read the database in an online server.
    It works on the project in Visual Studio 2013 C ++. Follow the design codes:


    Code:
    String^ PATH = L"datasource=mysql1.alwaysdata.com; username=dbuser; password=p@ass8585";
    MySqlConnection^ conDataBase = gcnew MySqlConnection(PATH);
    MySqlCommand^ cmdDataBase = gcnew MySqlCommand("SELECT * FROM nouruem_otz.usuarios"), conDataBase);
    MySqlDataReader^ myReader;
    try
    {
    	conDataBase->Open();
    	myReader = cmdDataBase->ExecuteReader();
    	conDataBase->Close();
    
    	MessageBox::Show("User and password successfully inserted!");
    	}
    		catch (Exception^ ex)
    	{
    	
    	MessageBox::Show(ex->Message);
    }
    NOTE: Not a lot of attention to the SQL command, I put this only as an example.


    To operate this project in C ++, I added an external reference named MySQL.Data.dll.

    I'm using namespace below.

    Code:
    using namespace MySql::Data::MySqlClient;
    The goal is that the database be "stored" in a web server.

    Thank you in advance any help.

    #2
    Hi, I see that you are using C#'s library to connect ot MySQL. I managed to get working C++ library. When I get hope I will upload the .dll file that is used for UE4. Cuz there are two versions, one for VS2013 and one for UE4.
    Raise the Black Flag!

    - [TUT]: HTTP GET Request in C++
    - [Tool]: Game Site Tracker website for your project
    - [Website]: Website for my game Leviathan

    Comment


      #3
      Did not quite understand.

      MySQL itself already be releasing the DLL to work with UE4 or you could make that MySQL connection and UE4 on their own?

      Anyway, I appreciate the response.

      Comment


        #4
        When I tried connecting UE4 to MySQL first thing was to look for a UE4 class to connect to MySQL but all I found was Http class to sent post requests to web server. Then I started a thread about which is better:
        Sending information to web server, and from there save it in database, or directly send information from the game to the database. Most of the people there said it's better to send data from game directly to database. And a guy sent me this library:Download

        I believe the MD was for Visual Studio and MT was for UE4.

        I only tried using MD and managed to connect from console to database. I believe that connecting to MySQL via UE4 would require these steps:

        1. Import the .dll file to UE4 and include the headers wiki.unrealengine.com/Linking_Dlls
        2. Write a class with function to pull data from database, put data into database and delete data from database
        3. Create instances of this class wherever you need it and access those functions in your game.

        For example you wrote a class DatabaseConnection which has functions dbconn->query(FString query) which will execute a query on the database and stuff and save the result in a variable. Then use that variable to output the result in your game.

        Sorry for not replying for so long Hope that helps a bit. If you have problems with that feel free to find me on skype (uadmin1) and we can discuss this even further!
        Raise the Black Flag!

        - [TUT]: HTTP GET Request in C++
        - [Tool]: Game Site Tracker website for your project
        - [Website]: Website for my game Leviathan

        Comment

        Working...
        X