i created a sql database with table land.

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

can anyone give me a good direction. i did a lot of google search. but cant find something usefull.

Hey, try this one, I just learn if from http://www.codeproject.com/KB/cs/upload_Images_to_DataBase.aspx

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;



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;


return1 = cmd.ExecuteNonQuery(); 



catch(Exception ex)

return return 1;


You'll have to trust me on this, but you really DO NOT WANT to store the image in your database. Instead store a file path or Uri to the image in your database and read it from disk when you want to display it.