0
hmm... I'm running ouf of ideas.
Could you post your code for the TableAdapter?
0
tadapt_player is a TableAdapter referencing the sql table or function that I am calling (insert_player)
The following is the code for Insert_player
INSERT INTO [player] ([Image_name], [Image]) VALUES (@image_name, @image)
The function is not recursive. When I debug, the error comes when I runs for the first time.
0
tadapt_player.Insert_player(image_name ,image)
what data type is tadapt_player?
Where is the code for tadapt_player.Insert_player(image_name ,image) ?
If ever this is a recursive call, then it will have an endless loop that will lead to memory problems
0
There is one error in the code I posted.
db_interface.Insert actually calls the Insert_player function.
0
Hi,
Thanks for the replies.
The SQL server field image can hold images from 0 to 2147483647 bytes.
That is, 100 bytes should not be the problem. Although Komal Patel you
have given me possible alternative solution. Maybe not the prettiest ..
but a solution :)
The following is the code I use , it shows ...
how I open the picture with opendialog
Convert the image to byte[]
display the picture in a picturebox
and call my database interface class, that inserts the data to the database.
....
openFileDialog1.ShowDialog(); // get image.
Image img = Image.FromFile(this.openFileDialog1.FileName);
image_name = "tester.jpg"; //string
image_buffer = imageConverter.imageToByteArray(img); //byte[], this I save to db
pictureBox1.Image = img;
The following is the imageToByte.. function.
public byte[] imageToByteArray(System.Drawing.Image imageIn)
{
MemoryStream ms = new MemoryStream();
imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
byte[] retArray = ms.ToArray();
ms.Close();
return retArray;
}
The following is the code for when I try to insert the data into the database.
db_interface is a class the I use for db functions.
db_interface.Insert(image_name, image);
The following is the Insert function
public void Insert_Player(string image_name ,byte[] image )
{
try
{
tadapt_player.Insert_player(image_name ,image); //This is the line that it crashes.
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}

0
hmm... your image size is just 9kb. Memory shouldn't be a problem here.
Could you post some code? Thanks.
0
hi
that might be because of limitation of image field in database...
in that case u can try saving only filename to database and save image to the folder in your project folder using Fileupload.SaveAs() method