1

I need to make a windows service that will get the data from serial port and write them into the database.

I am using a card reader so the port will get the cardId and datetime when the card was registered.

This information will be written into the database.

I wanted to ask if this is possible to be done in windows service. Should I write a function about it in the windows service program.

I found a solution in this link : http://blogs.msdn.com/b/bethmassi/archive/2007/05/05/reading-from-a-serial-port-and-saving-to-a-database.aspx but I don't know if this can be done inside the windows service.

Beslinda N.
  • 4,808
  • 5
  • 27
  • 33

1 Answers1

3

I cannot speak specifically to reading data from a serial port given that I have not done so personally, but there is no reason that this cannot be accomplished from a Windows service.

To start, you need to create the Windows service. I've got a couple of step-by-step instruction sets for doing that here and here. The first link shows you how to create a Windows service with Visual Studio and how to install it with the InstallUtil.exe utility. The second link shows you how to modify the service so that it can install itself without the need to use the InstallUtil.exe at all.

From there, you can add whatever logic you'd like. In my application, for example, I am currently reading Ethernet-based data using WinPcap and storing that in a SQL Server Compact database, so yes, it can be done.

HTH

Community
  • 1
  • 1
Matt Davis
  • 45,297
  • 16
  • 93
  • 124