Hey everyone, One topic which keeps coming up is how to access your database, particular Sql Server. I've been answering these questions and pushing people in the right direction, but I've now done a blog post with some server code (ASP.NET) and a MoSync project. The MoSync project gives you a new set of query classes: SQLQuery, NonQuery and SProcQuery which will execute your SQL against the ASP.NET code and a new set of data classes: DataSet, DataTable, DataRow which work just a very little bit like ADO. I've done all of the patching together and creating datasets from the XML returned by the website, so now you can all do:
class MyQuery : public QueryListener
{
private:
SQLQuery* q;
public:
MyQuery()
{
q = new SQLQuery("http://www.mywebserver.com/MoSyncData/", this);
q->execute("Select * from items where itemId = 4");
}
void queryReady(int resultCode, DataSet& results)
{
if(resultCode == 200)
{
//Read item name from table 0, row 0
String itemName = results[0][0]["ItemName"];
}
else if(resultCode == 500)
{
//Server error, probably bad SQL
}
else
{
//Network or IIS error
}
}
};Hopefully this is simple enough that everyone can just see how to use it from this code.
Detailed instructions can be found on the blog http://www.mosync.com/blog/2011/02/database-connections-mosync, but ask support question in the forum as I'm not alerted to comments on the blog.