473,395 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

FileUpload - inserting image into mysql

Hello,

I need to insert BLOB into MySQL DB from a C#.NET 2.0 environment. The
piece of code which I am using is listed below.

Note: fileup is a FileUpload holder
<code>
Stream content = fileup.PostedFile.InputStream;
byte[] bytedata = new byte[fileup.PostedFile.ContentLength];
int n = content.Read(bytedata, 0, fileup.PostedFile.ContentLength);

odbcCommand.Connection = odbcConnection;
odbcCommand.CommandText = "insert into images.profke(id, image)
values (1,"+ bytedata + ")";
</code>

On debugging, the value held by 'bytedata' is 'System.Byte'.
bytedata.getValue() lets me access individual elements in the byte
array. How do I insert the entire content of the byte[] in to the
database.

Thanks in advance,
Narmatha

Mar 25 '06 #1
0 1472

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eric | last post by:
I'm using the fileuploadcontrol for the user to select a file, in this case a image file. I would like to see the little preview image to be shown right after selection, but there seems to be no...
0
by: Christian Schlemmer | last post by:
If my code will run into the filesize-limit condition, the INSERT-statement will be executed. is there a way to avoid that? Protected Sub DetailsView1_RowInserting(ByVal sender As Object,...
3
by: rn5a | last post by:
The ASPX FileUpload control displays a TextBox along with a 'Browse...' Button. Setting the different properties of this control just reflects the changes in the TextBox but not the Button. For...
4
by: ronc85 | last post by:
I'm using ASP.NET 2.0 and C#. With the FileUpload control is it possible to set Wildcards (e.g., *.xls and *.doc) so that when the user clicks the Browse button it defaults to Excel and/or Word...
4
by: Mukesh | last post by:
i have coded like this <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="Label1" runat="server"> <asp:FileUpload ID="fupLogo" runat="server"...
0
by: =?Utf-8?B?Z292ZXI=?= | last post by:
Hello, I have a Formview in insert mode with a fileUpload control on it. I'm trying to get the contents of the uploaded file passed to my ObjectDataSource to be persisted to my database. The...
0
by: pieandpeas | last post by:
Hi, i've got a required field validator set to check if a file being uploaded (via a fileupload control) is a valid image (jpg or gif), it works , to a point, When an item is selected which...
6
by: =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post by:
I have created a simple fileupload page for image files. It woulds without problem with ie7. However, FireFox and Safari will not upload an image file. Is there some issue with the control and...
4
by: ghjk | last post by:
I wan to add some data using php page to mysql db. But I got the error saying "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.