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.
Asked
Active
Viewed 2,433 times
-3
-
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 Answers
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
-
Thank You Sir...i will try it....and back again here...when i m done doing this... – Being Sufiyan Mar 21 '13 at 11:10
-
I'll remove the downvote if you change "binary" to "varbinary(max)". Binary datatype in SQL Server is for fixed length binary columns only. See http://msdn.microsoft.com/de-de/library/ms188362.aspx – TToni Mar 21 '13 at 11:15
-