| | |
import image to db
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
i created a sql database with table land.
columns;
LandID int PK
LandCodeID int
LandName nvarchar(100)
LandFlag image Allow Nulls
ive created a dataset in my solution.
from my Data Sources i can drag & drop the table Land to my Form1 as DataGridView. it puts all the columns above on my form. im able to update/add/delete Lands except the flag. i want to double click on the landFlagPictureBox so i can select the jpg image to save it in my database. can anyone help me out?
thanx in advance
columns;
LandID int PK
LandCodeID int
LandName nvarchar(100)
LandFlag image Allow Nulls
ive created a dataset in my solution.
from my Data Sources i can drag & drop the table Land to my Form1 as DataGridView. it puts all the columns above on my form. im able to update/add/delete Lands except the flag. i want to double click on the landFlagPictureBox so i can select the jpg image to save it in my database. can anyone help me out?
thanx in advance
Last edited by karabela; Aug 4th, 2008 at 1:07 pm.
•
•
Join Date: Jun 2006
Posts: 37
Reputation:
Solved Threads: 2
Hey, try this one, I just learn if from http://www.codeproject.com/KB/cs/upl..._DataBase.aspx
C# Syntax (Toggle Plain Text)
Stream streamImage=file1.PostedFile.InputStream; int imageLenght=file1.PostedFile.ContentLength; string strType=file1.PostedFile.ContentType; string strType1=file1.Type; string strName=txtName.Text; Byte[] imgData = new byte[imageLenght]; int n = streamImage.Read(imgData,0,imageLenght); int result = saveImage(strName,imgData,strType); private int saveImage(string strName,byte[] imgData,string strType) { int return1=0; try { SqlCommand cmd= new SqlCommand("INSERT INTO image1(id,imageLenght,imgtype,bytles) values (@id,@imageLenght,@imgtype,@bytles)", con); cmd.Parameters.Add("@id", SqlDbType.VarChar).Value = strName; cmd.Parameters.Add("@imageLenght", SqlDbType.BigInt).Value = imgData.Length; cmd.Parameters.Add("@imgtype", SqlDbType.VarChar,6).Value= strType; cmd.Parameters.Add("@bytles", SqlDbType.Image).Value = imgData; con.Open(); return1 = cmd.ExecuteNonQuery(); con.Close(); } catch(Exception ex) { Response.Write(ex.Message); } return return 1; } finally { con.Close(); }
Last edited by Tekmaven; Aug 8th, 2008 at 4:43 pm. Reason: Code tags
![]() |
Similar Threads
- Paste a image into another (Python)
- Putting an image into a Tkinter thingy (Python)
- Image and ImageTk weirdness (Python)
- Image handling in Adobe (Graphics and Multimedia)
- Tkinter Image Problem (Python)
- Doubling the size of an image (Python)
Other Threads in the C# Forum
- Previous Thread: compare files in c#
- Next Thread: how to extract substring from a string?
| Thread Tools | Search this Thread |
.net access algorithm alignment app array barchart bitmap box broadcast c# c#gridviewcolumn cast check checkbox client combobox communication control conversion csharp custom database datagrid datagridview dataset datatable datetime degrees development draganddrop drawing elevated encryption enum excel file focus form format forms function gdi+ hospitalmanagementsystem httpwebrequest image index input install java label list listbox localization login mandelbrot math messagebox mouseclick mysql operator path photoshop picturebox pixelinversion plotting pointer post programming radians read regex remote remoting richtextbox server sleep socket sql statistics stream string stringformatting sun table text textbox thread time timer update usercontrol validation visualstudio webbrowser whileloop windows winforms wpf xml





