• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SQL or MySQL?

M

Mholmes3038

Guest
Is there a way to store data via SQL or MySQL using Game Maker Studio? If so does someone have samples of the function? Thanks in advance
 
M

Mholmes3038

Guest
Anyway to do it via ASP or another route? I'm not a php kinda guy. I think I've worked with php maybe twice.
 

Llama_Code

Member
You could do if with anything that accepts URL parameters and interfaces with a database. The GameMaker functions would be the same regardless, mainly http_get and http_post_string, look up asynchronous functions in the manual. Those examples will give you a good start regardless, the will show you how it works on the GameMaker side of things.

The script will do all the database transactions. What I usually do is call the script with URL parameters just link a web page, then echo the output and you can get that returned in GameMaker.
 
M

Mholmes3038

Guest
Wow ok great. I have a class already with my sql functions and my connection strings setup already. I've not worked with html post yet but I think I see what your saying now. Thank you guys very much this was super helpful.

Here is my class incase someone needs a example as well:

Code:
//Command
        private SqlCommand SP = new SqlCommand("StoredProcedureName");

        //Product
        private string Product = "Sharp Control";

        //Application Connection
        private SqlConnection cn = new SqlConnection("Server=www.YourURL.net;Database=YourDataBaseName;User ID =YourApplicationDataBaseUserID; Password =YourApplicationDataBasePassword");
Code:
public bool FunctionName(string _Class, string _Method, string _Exception)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("Stored_Proc_Name_Here", exCon);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                bool Success = false;

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@Product", Product));
                cmd.Parameters.Add(new SqlParameter("@Class", _Class));
                cmd.Parameters.Add(new SqlParameter("@Method", _Method));
                cmd.Parameters.Add(new SqlParameter("@Exception", _Exception));
                cmd.Parameters.Add(new SqlParameter("@Success", Success));
                exCon.Open();
                Success = Convert.ToBoolean(cmd.ExecuteNonQuery());
                exCon.Close();

                return Success;
            }
            catch (Exception)
            {
                exCon.Close();
                return false;
            }
        }
 
Last edited by a moderator:
What databases does Game Maker Studio support?
Externally? None, natively, that I'm aware. All, using the properly documented API available everywhere.
Internally? JSON via converting between data structures, structs, and arrays <---> your text-based files (encrypted or not).

I hope this helps,
Bob
 
Top