So far I have used an open file dialogue and a picturebox where the user can browse for images and preview it. The code I have used for this is ;
//open the BtnBrowse dialog
OpenFileDialog BrowseDialogue = new OpenFileDialog();
//Select filters on which file types to upload
BrowseDialogue.Filter = "Images Files (*.jpg; *.jpeg; *.gif; *.bmp; *.png:)|*.jpg; *.jpeg; *.gif; *.bmp; *png;";
if (BrowseDialogue.ShowDialog() == DialogResult.OK)
{
//Preview the image in a picturebox
pictureBox1.Image = new Bitmap(BrowseDialogue.FileName);
//Display image path in textbox
textBox1.Text = BrowseDialogue.FileName;
The above code all works fine but I now want to have an upload button where the image in the picturebox is uploaded to the database, I understand that there are two ways of doing this via file stream or memory stream.
The table name I wish to upload to is contents and the field name is image.
Could someone provide me with some information of how to go about this?
Many thanks for your help.
SakthisPosted Oct 15, 2013, 4:42 AM
Lynn EmeryPosted Oct 15, 2013, 4:17 AM
For the code which is related to the SQL connection, i am a little confused. Do I need to define the security etc?
sqlcon.ConnectionString = "Data Source=sakthi\\sqlexpress; Initial Catalog=LoginDetails; Integrated Security=True";
Could please explain further?
I have a data source called ProductImages and are using SQL server 2003.
Thank you once again.
SakthisPosted Oct 14, 2013, 12:01 PM