1
Answer

Please Help: Is WCF Best Way To Update Client "Compact 3.5" db from "Sql Server"???

Photo of Jason Wu

Jason Wu

14y
8.1k
1
Hello,

I'm new to this, so I hope someone can help me out...

We have an "in-house" application that we have developed in WPF reading a SQL Server 2008 Database.  We are able to deploy this to the various clients via ClickOnce.

The question is, some of this data on the SQL Server 2008 Database can change.  We want a good reliable way to have this data downloaded to the client "Sql Server Compact 3.5" Databases.

Is WCF the way to go?  Do I need to create routines to create an xml file from the "SQL Server" data, then upload it into the "Sql Server Compact 3.5" Database?

Can anyone give me some advice on how to proceed?  Are there good tutorials or articles out there?

Thanks
Jason

Answers (1)

0
Photo of Datta Kharad
NA 2.5k 40.9k 13y
Hi
   Declare array outside the for loop and get another variable total for sum...
You can display each number which is meet your condition i,e multiple of 3 or 5 and Lastly display Sum of these numbers. Use this code:-
using System;


namespace test
{
class Program
{
static void Main()
{
Program p = new Program();
p.sum(1000);


Console.ReadLine();
}


public void sum (int tal)
{
long total = 0;
int[] array= new int[1000];  //It does save in Array..(Here your problem get solved)
for (int i = 1; i < tal; i++)
{
if (i % 3 == 0 || i % 5 == 0)
{
array[i] += i;
 total = total + i;
Console.WriteLine(array[i]);
}
}
Console.WriteLine("Sum of multiple 3 or 5 below 1000= "+total);
}
}
}
Accepted
0
Photo of Datta Kharad
NA 2.5k 40.9k 13y
Hi
   If your query resolved then mark as Correct Answer.
0
Photo of Zu Sung Park
NA 5 2.4k 13y
Thank you so much! :) I used this tips since I wanted to use Array.
0
Photo of Zu Sung Park
NA 5 2.4k 13y
Thank you so much! :) Good tips!
0
Photo of Armando Pinto
NA 2 0 13y
Hi.

Looking at your code I'm not sure of what you want to do... 

If you want to get the total sum, you should maybe do something like this:

namespace test
{
  class Program
  {
        static void Main(string[] args)
        {
                long totalSum = Sum(1000);
                Console.WriteLine(string.Format("Total sum: {0}", totalSum));
                Console.ReadLine();
        }

        public static long Sum(int tal)
        {
                long total = 0;
                for (int i = 1; i < tal; i++)
                {
                        if (i % 3 == 0 || i % 5 == 0)
                        {
                                total += i;
                        }
                }

                return total;
        }
   }
}