WinCE Data Communication Web service Chapter

Source: Internet
Author: User
Tags dot net httpcontext web services visual studio

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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.