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 :-)
I don't care what your requirement says, do not insert an excel document into a sql server varbinary(max) column. The requirement should say "Upload an Excel document, insert its contents into a database. However, we need to relate the original excel file to the data within the database so we can repudiate any claims that our process failed as well as have a verification mechanism."
or less the following columns
Check the extended property I put on there for column clarifications
Some other thoughts