Connecting to external SQL Server via ODBC

Hi :slight_smile:

In our development it is really crucial that we are able to connect to a external SQL Server (MSSQL) to make queries and to update data from the game to this server.

We have not been able to find any documentation on how this can be achived, maybe throug ODBC or something… the closest we have found is a old component called LuaSQL, but we are really uncertain if this could work with Corona SDK, and we also would prefer to use a Corona dedicated way of doing this.

Can anyone help us in the right direction? :slight_smile:

Best Regards

Stig :slight_smile: [import]uid: 123415 topic_id: 21253 reply_id: 321253[/import]

No one that can help on this, Please? [import]uid: 123415 topic_id: 21253 reply_id: 84487[/import]

I’m interested in this too.

Of course, you could also create a series of RESTful web services that handle your CRUD. If your web services returned JSON it would play very nicely with LUA and Corona. [import]uid: 60707 topic_id: 21253 reply_id: 84559[/import]

Hi Chris,

Thanks for your reply :slight_smile: … The model you are talking about, could you explain a little more about that? :slight_smile:

/Stig :slight_smile: [import]uid: 123415 topic_id: 21253 reply_id: 84614[/import]

Stig,

Sure. Let’s assume you want to get the total “coins” player17 has earned from your database. First you’ll you write a bunch of “web services” that can perform select’s, inserts, updates and deletes on your database. Now, let’s pretend you point your web browser at your web service for querying data about a player: http://example.com/players/player17

Instead of “html” your webservice should return json data that looks like this:
{
“playername” : “player17”,
“coins” : 153,
“location” : “AZ”
}

Cool, so how do you use that in Corona? Your App should do something like this (untested btw)…

[lua]local json = require “json”

local function networkListener( event )
if ( event.isError ) then
print( “Network error!”)
else
print ( "RESPONSE: " … event.response )

local t = json.decode(event.response)
print(t.playername) --> player17
print(t.coins) --> 153

end
end

– Access Your web service using HTTP
network.request( “http://example.com/players/player17”, “GET”, networkListener )[/lua]

P.S. Read about REST here: http://en.wikipedia.org/wiki/Representational_state_transfer
[import]uid: 60707 topic_id: 21253 reply_id: 85050[/import]

Hi Chris,

Thank you very much for that great explanation, and sorry for the late reply!!

I will study the material thorougly, and I think that will be the way to go for us… thanks :slight_smile:

/Stig :slight_smile: [import]uid: 123415 topic_id: 21253 reply_id: 85633[/import]

No problem. You might try checking out Amazon’s SimpleDB. It provides a simple web services interface to create and store multiple data sets, query your data easily, and return the results.

That means you wouldn’t have to write your own webservices to interface to your database. The catch is that SimpleDB is not a relational database, and Amazon’s web services return xml, not JSON so you’d have to deal with that. [import]uid: 60707 topic_id: 21253 reply_id: 85637[/import]