Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want to develop an application in C#, Visual Studio .NET 2008. In which Server Application writes the result of datagridView in Dataset, and other Client application will read that data.
I developed a sample application in which server application writes the string data, and client application read that string data. The code on server side is

C#
using (NamedPipeServerStream pipeServer =
        new NamedPipeServerStream("testpipe", PipeDirection.Out))
            {
                Console.WriteLine("NamedPipeServerStream object created.");

                // Wait for a client to connect
                Console.Write("Waiting for client connection...");
                pipeServer.WaitForConnection();


                Console.WriteLine("Client connected.");
                try
                {
                    // Read user input and send that to the client process.
                    using (StreamWriter sw = new StreamWriter(pipeServer))
                    {
                        sw.AutoFlush = true;
                        Console.Write("Enter text: ");
                        sw.WriteLine(Console.ReadLine());
                    }
                }
                // Catch the IOException that is raised if the pipe is
                // broken or disconnected.
                catch (IOException e)
                {
                    Console.WriteLine("ERROR: {0}", e.Message);
                }


The code on client side is

C#
using (NamedPipeClientStream pipeClient =
        new NamedPipeClientStream(".", "testpipe", PipeDirection.In))
            {

                // Connect to the pipe or wait until the pipe is available.
                Console.Write("Attempting to connect to pipe...");
                pipeClient.Connect();

                Console.WriteLine("Connected to pipe.");
                Console.WriteLine("There are currently {0} pipe server instances open.",
                   pipeClient.NumberOfServerInstances);
                using (StreamReader sr = new StreamReader(pipeClient))
                {
                    // Display the read text to the console
                    string temp;
                    while ((temp = sr.ReadLine()) != null)
                    {
                        Console.WriteLine("Received from server: {0}", temp);
                    }
                }
            }
            Console.Write("Press Enter to continue...");
            Console.ReadLine();


This works fine, But now I want that Server application write a datagrid view data in datatable/dataset, and client application read that datatable and bind to client's DataGridView.

I used System.IO.Pipes for above task.

Thanks in advance for your help.

Regards

Nauman
Posted
Updated 22-Jun-10 2:45am
v3

1 solution

And what is the problem or question you have? Serialize the DataSet.

Also, I would use WCF, which can use named pipes, to provide greater flexibility, managebility and extensibiliy.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900