Ready to write a wince platform and database server data communication Interactive aspects of the article, today, first of all to tidy up a Web service communication methods.
The company's current hardware products platform is WinCE5.0, data communication is connected to the terminal bridge, the relationship between the terminal data can be accurate and timely and efficient arrival of the server, is the key to the success of the project. The former company has a colleague with VC wrote a program with sockets for data communication, but has been a problem constantly. Years ago, I began to explore the use of SQLCE and SQL Server data synchronization methods for data upload and download, communication has been normal and stable. This article follow-up to the reorganization.
There are many articles on the Web service for communication between PCs, but the experience for WinCE platform invoke is not very good. Web service programming and configuration calls are relatively simple, and Visual studio creates a Web services project directly by creating a new "ASP.net Web server application." The code is written according to the actual requirements, which is not detailed.
Terminal equipment is through GPRS for data transmission, therefore, data traffic is very important problem, should be as little as possible to reduce data transmission, traffic is money, compression technology is the key. Google Dafa, found a cheap dongdong-ihttp://www.icsharpcode.net/opensource/sharpziplib/default.aspx so-called beauty is this code support dot net CF platform, The so-called cheap is this code completely open source free.
Fencing start ... Build a Web services service that directly returns the dataset set
Private SqlConnection Conn;
private string connstring = "Data source= (local); Initial Catalog=northwind;uid=sa;pwd=sa;";
Dataconnection#region DataConnection
Private DataSet Getnorthwinddataset ()
{
Return ExecuteSQL ("SELECT * from Employees");
}
Private DataSet ExecuteSQL (string mysql)
{
DataSet DataSet = new DataSet ();
SqlDataAdapter adapter = new SqlDataAdapter (MySQL, this. Conn);
Try
{
if (this. Conn.state = = connectionstate.closed)
{
This. Conn.Open ();
}
Adapter. Fill (DataSet, "table");
}
catch (Exception Exception)
{
HttpContext.Current.Response.Write (Exception. message);
HttpContext.Current.Response.End ();
}
Finally
{
if (this. Conn!= null) && (this. Conn.state = = ConnectionState.Open))
{
This. Conn.close ();
}
Adapter. Dispose ();
}
return dataSet;
}
#endregion
Method One: Return the DataSet object directly
[WebMethod (Description = "returns the DataSet object directly.) ")]
Public DataSet GetDataSet ()
{
DataSet = Getnorthwinddataset ();
return dataSet;
}