Question

i have a smart device that installed windows CE 5 on it. i want to write a c# program so that it install on smart device and can communicate to external database, this database is a SQL Server Standard or Enterprise Edition (not Compact Edition) and hosted on a PC. communication between device and PC are established through LAN.

so, i cant use System.Data.SqlClient namespace and it's classes, because this name space and it's classes dont recognize in windows CE. and too i cant use System.Data.SqlServerCe namespace and it's classes because i want to connect to External Enterprise SQL Server Database and this is not a SQL CE database.

how i can do this?

Was it helpful?

Solution

You can do it using this approach:

1-Develop a web service on the server , define web methods (as your app needs) inside it to deal with the DB e.g.

[WebMethod]
    public void ExecuteSql(string query)
    {
       SqlCommand cmd  = new SqlCommand();
       cmd.Connection = new SqlConnection("connectionstring");
       cmd.CommandType = CommandType.Text;
       cmd.CommandText = query;
       cmd.Connection.Open();
       cmd.ExecuteScalar();
       cmd.Connection.Close();
    }

2- make a reference to this web service in your windows CE app.

3- then you can call the web service methods and you can send and retrieve data.

Note : the web service deal with SQL mixed authentication not windows authentication.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top