How to pass an Excel file from a WinForms client to a WCF service and into an SQL Server table?
Can anyone provide any guidance, code, or advice?
- WCF service contract and implementation that will take an Excel file as a parameter
- Contract implementation should insert that Excel file into a varbinary(MAX) column in SQL Server.
I’m sure the experts out there can improve upon this, but here are the basics …
On the Server
1a. Add a new OperationContract to your Interface (eg. IService.cs)
1b. Insert into SQL Server table, in your contract Implementation (eg. Service.cs)
On the Client
2a. Use the OpenFileDialog component to browse for files on your filesystem using the standard dialogue box that’s used by most Windows applications.
2b. Load the file’s contents into a byte array
2c. Call your WCF contract, passing in the byte array
It’s working… YAY 🙂