Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good Morning fellows, I've searched all over the web and I haven't found how to save a file (given by the user) into a SQL database; I need to do it without paramaters because we're working on ASP.NET so it will slow our application too much.

Does anyone know how I can do that or does anybody have a link where I can get what I need.

Thanks in advance,
Daniel Gomez
Bogota Colombia
Posted
Updated 26-May-10 14:17pm
v4
Comments
Kythen 26-May-10 13:44pm    
Please include what SQL database server you are using (SQL Server/Oracle/etc.)

Also, using parameters will *not* slow down your application too much. Bad queries and poor database design are much more likely do affect performance.
DanielGomez 26-May-10 13:49pm    
ok, we're using SQL server 2000 as database, and yeah i get what you are saying, the little problem is the arquitecture that we're using doesnt allows to use parameters that's the problem

I think you can use something like this (but I'm not absolutely sure):

insert into blob_table(my_image) values(0xC9CBBBCCCEB9C8CABCCCCEB9C9CBBB);


0xC9CBBBCCCEB9C8CABCCCCEB9C9CBBB - it is image converted to its hexadecimal form.
 
Share this answer
 
v2
Comments
DanielGomez 26-May-10 16:42pm    
thank u so much i totally forgot about the hexadecimal.
any idea about how to get it back ?
I am assuming by "do it without parameters", you mean "do it without named parameters" (i.e., by passing the literal value). Aside from what the other person suggested, here is an idea...

You can always convert the binary data to and from a string (e.g., text or varchar). If the data is too large for, say, a varchar(8000) and you can't use ntext, you can always split the data and make multiple calls to get/set each chunk of it.
 
Share this answer
 
Comments
DanielGomez 27-May-10 11:19am    
thanks for the effort sir, but we try the first answer now the probkem is how to get it back to the normal file type, cause i keep getting the hexadecimal form.
ANY ideas ?
What do you mean, you get the "hexadecimal form". That's just one way you represent binary data, but under the hood it's still just binary data. Files also just store binary data. Usually that binary data is represented in VB.Net and C# as an array of bytes. Perhaps you should update your question with some code that demonstrates the problem you're having with converting the data types.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900