0

I would like to know how to save a document(txt,pdf,doc,docx,xls etc) to Microsoft SQL Server using C# windows forms. Here's the form I've designed File Upload Box. I've used the openfiledialog box but I couldn't select a file. Any help would be appreciated. Thank You!

Also what kind of datatype should be used to save file in Microsoft SQL Server? Thanks!

OpenFileDialog OpenFileDialog1 = new OpenFileDialog();
            OpenFileDialog1.Title = "Select a Document";
            if (openFileDialog1.ShowDialog() == 
System.Windows.Forms.DialogResult.OK)
            {
                this.Cursor = new Cursor(openFileDialog1.OpenFile());
            }
Varun ks
  • 13
  • 4
  • What do you mean you couldn't select a file? What happened if you clicked on something? Also regarding the datatype to store it as in SQL, you can find more info here: https://stackoverflow.com/questions/13420305/storing-files-in-sql-server – Christopher Lake May 31 '17 at 06:47
  • I got an error saying "Image format is not valid. The Image may be corrupted. Parameter name: Stream". I'm adding the code in the question – Varun ks May 31 '17 at 08:04

1 Answers1

0

Kindly refer below pointers and use it as per your requirement.

Link1

Link2

Link3

Ashok
  • 1,868
  • 6
  • 36
  • 70