Search Unity

MS SQL integration

Discussion in 'Scripting' started by Michieal, Sep 17, 2016.

  1. Michieal

    Michieal

    Joined:
    Jul 7, 2013
    Posts:
    92
    This really isn't a question per se, but more of a request...
    Could Unity do a SQL Integration guide? I've been searching the forum posts and help and documentation, and it occurs to me, that if one is going to use UNetworking (or even a 3rd party add on, like Photon), that the server side of it needs to easily be able to integrate things like MS-SQL transactions so that we can use stored procedures on the server side.
    I really cannot see a MMO being done without it... All of the posts that I see are the same "Yep! It just doesn't work..." or "use a web interface" etc.
    While I wouldn't want the client side to have it, I would definitely want the server side to have this, and NOT have to go through 30 layers of web look ups just to get a piece of data to push to the client. There's got to be a better way... Like, oh... I don't know... the way that regular programs do it (that I write daily for various industries around the state).
    "It sure would be nice..." to be able to just take what I know how to write, and drop it into Unity (being that both are in C#) and just go. that way, I could just get back to making games and not hitting a Snag. At. Every. Step. Of. The. Way.
    And, I think others feel the same way -- if the forum help areas are any indication.
     
  2. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    There are reasons why it's common to have sort of data layer like a web service between the game server and database especially with online games where you often want to do small tweaks while running live. I would not skip things just because things seem simpler without them. Actual game servers should be as simple as they can when it comes to storing persistent data.
     
    Michieal likes this.
  3. Vedrit

    Vedrit

    Joined:
    Feb 8, 2013
    Posts:
    514
    There are plugins you can use, and I believe there's a System.SQL or something. Just nothing officially supported, AFAIK, which makes sense, if you think about it; Unity Networking isn't exactly in a completed state. If it's not completed, you can't really expect it to have these advance features like querying a SQL database.
     
    Michieal likes this.
  4. Michieal

    Michieal

    Joined:
    Jul 7, 2013
    Posts:
    92
    Well, from what I have seen, even with Photon's networking (which Nintendo pushes, btw) the idea is that you make the server and the client at the same time, so that you can see it connect, and you can see how it inteacts. then when you build the server itself, you make it headless... so, that the server is using less resources. But, having server side authentification is preferable... and there's many instances where you don't WANT to use a web interface. I myself, have one such, and have mentioned it above... Meaning that Unity needs to access this.
    In an rpg, for instance, you want to be able to access and update things without waiting on many different layers to complete. One of the biggest issues that people have in the newest update of WoW (Blizzard) is that they slowed down the network updates for the client, and it runs like crap even on high end machines.
    I dislike copying other's mistakes because someone wants to make a simple function as obtuse as possible due to not putting in a compatible library. And, if you do use the Mono versions of System.Data.SQL* it tells you that you are missing a reference when you're really not. Most are forced to default to setting up a web server, building a wep page to serve the data, and connecting to that web page via unity and hope that it works... Trust me -- I've scoured the forums...and I am saying something here because it really does seem like this is the most over looked aspect of the Unity Game Engine. (Which is the only thing that makes me not a "Unity Evangelist" in real life... you can't access databases which should be a no-brainer.)
    I'm not asking for it for a web page port of a game, but for the stand alone ports, this should have been built in and tested since 3.0!!!!!! It's enough to make unreal look appealing.
     
  5. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    Game server should mainly do things like cache data and handle game logic but the actual database layer should be a separate thing. Server should not even know what type database is behind everything and it should just communicate to it with some basic interface. It does not have to be a web server thing and you can use anything you want like even a visual basic app. Web services are the most common ones because the scalability is very easy with them and you can alter the code live to add things safety mechanisms or fix certain exploits without taking servers down. You can even have multiple type database engines in the backend without the need of updating the actual game server.

    This is not really engine specific design but very common one in the industry.
     
  6. Michieal

    Michieal

    Joined:
    Jul 7, 2013
    Posts:
    92
    I get what you are saying. I would quickly and easily write one in c# or vb (just due to ease) and have it connected to the client or a UNet based Unity server (so that the server can easily do bounds checking) but everything that I read, "UNet only connects to UNet" - whether it's true or not, I'm not sure. But judging by (again) the forum threads on putting database code into unity... it's networking either doesn't play well with others, or it's not optimized enough to work well through the different layers of apis, etc., to be a server so that you can use these networking schemes and have your database in house.
    I say this, because nowhere have I seen "Here's How to Connect to a non unity program with either Photon or UNet." just haven't. And, in the case of a stand alone game (thinking here 3-8 players rather than as MMO) for a LOT Programmers wiping out a quick database class that uses a stored procedure and a Role secured account is what they were taught in college, and it's a ton easier to them to do, than the whole web service. I know that I for one, simply don't have the time to set up a web service, write the asp, test that too for security.
    I guess that one could argue, "then use baas" like gamespark... well, it doesn't play that well with consoles and having tried a few different BaaS, I can honestly say I'm getting tired of learning new api's and having them break my games when they "update" their back ends... (Parse and Shephertz's app42 are horrible for this.)
    I dunno, I just want things to work smoothly, I don't want to argue it, It's a good suggestion, I've stated enough reasons that it should be there, and the forums have more than what I have stated... and you have unity as the greatest thing since Betty White... and when you go to use it, you hit either the "It's just not possible" wall or you hit the "you have to hire a team, because you don't have the time or skill to do something that should be so flipping simple" that it's highly off putting to indies. Because I can tell you - like me, they look at all of the games out there, analyze how they work, and then try to make that in unity and they hit idiotic, unintelligible snags and they think "wtf is wrong now? now why isn't this piece of @%$^%^@ game engine not working?!" And yeah, it might just be ignorance -- hence the first part of my lead post: "Could Unity do a SQL Integration guide?"
    And, I just don't want to hire someone to write a stable web back end to do this. I just don't. It should work. I personally don't have the time to build it myself... And, it's sooo not a lack of dedication--it's a lack of hours in a day plus having a life. This really shouldn't be this obtuse and sideways difficult. Hence me asking if it really could be addressed.
     
  7. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    Well if you really want to do the original question about sql it should be as easy as just including the System.Data in plugins folder and you should be good to go for MSSQL. It's a long time since I used it and it was with Firebird with extra dll but did not really have any problems. The networking part is a another question and personal preference. Unity has the low level api available to do almost anything and Photon comes with it's own guides.
     
  8. Michieal

    Michieal

    Joined:
    Jul 7, 2013
    Posts:
    92
    It gives a "Missing Reference" error. It was (for me) the first thing that I tried, as I have a .NET class already made. Then I went searching the forums and the manual, and the scripting guide, I googled it and spent about 3 days on it looking for how to get the error to go away to find out that Unity doesn't play well with the mono .dlls... and not to use them.
    And, I found out that pretty much, most people have this issue, and it's been on-going. So, I thought that the brilliant idea would be to ask for this as a guide, so that the question and annoyance goes away... because this is one of those things that no one from Unity Technologies seems to ever touch. It's either a thread full of "Me Too"s or it's "I found this out: you sacrifice a goat to the dark gaming gods, offer 3 virgins of different, non-earthly species, and do a little dance.... and if they smile upon you in favor it will work." I guess I am just not into voodoo enough! :p
     
  9. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    Where does it say that? I quickly tried with some copypaste and empty project, no errors in Unity or Visual Studio :)

    upload_2016-9-20_17-48-51.png
     
    Smalfy likes this.
  10. Michieal

    Michieal

    Joined:
    Jul 7, 2013
    Posts:
    92
    Okay, so I grabbed them out of the ...\Program Files\Unity\Editor\Data\MonoBleedingEdge\lib\mono\unity directory, I made effectively the same sqltest file that you did. and I am no longer getting the missing reference error, but it needs Mono.Data.TDS.dll. Which, is still better than what I have gotten before.
    upload_2016-9-20_12-9-27.png

    But, adding that file in...
    I run it again and I get this:
    upload_2016-9-20_12-13-9.png

    I have to say, this is the farthest that I have ever gotten this to work. I'm amazed and shocked at the same time. Usually, I hit so many walls that I got cross-eyed with frustration and annoyance. And the insult to the injury is that in a standard application (both C# and VB) I write programs used in the automotive industry on a daily basis.

    :D !!!
     
    Ostwind likes this.
  11. Michieal

    Michieal

    Joined:
    Jul 7, 2013
    Posts:
    92
    Ostwind,
    Thank you, for myself, and for others -- I know personally, this has been a brick wall that I have gotten annoyed at hitting my head against and thinking "I know I am not this inept! Why won't it work."
    So, a heartfelt Thank you! :D
     
    Smalfy and Ostwind like this.