-3

I am creating a c# windows application and i want to save and retrive a rar or zip file to sql server.Is there any way to insert a .rar or .zip file to SQL Server and get it back again? Please Help Me.

ruchi
  • 996
  • 12
  • 30
Being Sufiyan
  • 67
  • 1
  • 10
  • Have you tried storing it as BLOB? – Yahya Mar 21 '13 at 11:06
  • You can save it as a binary datatype. – RB. Mar 21 '13 at 11:06
  • i have no idea how to do it using blob or binary....please any one of you can provide me code for this... – Being Sufiyan Mar 21 '13 at 11:09
  • 1
    @BeingSufiyan you cant get the code, but you can get the resources to read . http://msdn.microsoft.com/en-IN/library/ms131092(v=sql.100).aspx and http://stackoverflow.com/questions/1064121/how-do-i-insert-a-byte-into-an-sql-server-varbinary-column – Ravi Gadag Mar 21 '13 at 11:10

1 Answers1

2

Create a column of type varbinary(max). In C# you can insert/select the content as a byte[]. You can use File.ReadAllBytes or File.WriteAllBytes to get the file content as byte[] or write it.

And remember: you can always use Google, too!

Thorsten Dittmar
  • 55,956
  • 8
  • 91
  • 139