There are a lot of possible reasons why this doesn't work:
1) The "net time" command could be returning:
"Could not locate a time-server.
More help is available by typing NET HELPMSG 3912."
2) You could be trimming out the wrong bits of the returned string
3) You could be converting the "output" string to bytes wrong.
4) You could have the communications parameters set wrong.
So: Check things:
1) Log the response to "net time" to either a log file, the console, or to the screen via a message box. Also log your "output" string. If that looks right, move on
2) Log the data you are sending to the communications device in the same way: it should be four characters "9:26" in your example
3) Try replacing your (odd and probably the problem) conversion routine with this:
getnettime();
byte[] buffer_2_storetime = System.Text.Encoding.ASCII.GetBytes(output);
_serialPort.Write(buffer_2_storetime, 0, buffer_2_storetime.Length);
And then send that instead.
4) Check what the communications parameters should be, and double check you have matched them.
It is important to check these in this order - otherwise you won't know what the heck is going on.
"Thanks for taking your time.
net time does returns the server time and i have trimmed that output to be displayed in the textbox and it displays correctly.
still something is wrong at:"
byte[] buffer_2_storetime = System.Text.Encoding.ASCII.GetBytes(output);
_serialPort.Write(buffer_2_storetime, 0, buffer_2_storetime.Length)
Don't answer via the Add Answer button - only you would get an email notification that way. Instead, respond with a comment on my answer so I get an email!
If the value in "output" is displaying in your text box correctly, then I would check your settings - make sure your baud rate, Bpc, parity, etc are all as expected by your device.
Put a breakpoint on the SerialPort.Write and examine the buffer - it should be fine if the "output" string is ok.
Then, check your device is not expecting any leading and/or trailing codes to indicate this is a time code.
Finally, use Hyperterminal or similar to talk directly to the device and type in exactly what you think you are sending. Does the device respond ok?