473,324 Members | 2,473 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,324 software developers and data experts.

how to insert and retrieve images from sql databasee...

hi

i am trying to store images in sql database in binary form .. i do it
..... but when i want to show that stored images on my web form any
where i got only first 16 bytes of the image. so i got error and cant
display the image. but can store it successfully.

plz help me and guide me its urgent

thanx

Aug 16 '06 #1
3 1780

"Umar" <me************@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
hi

i am trying to store images in sql database in binary form .. i do it
.... but when i want to show that stored images on my web form any
where i got only first 16 bytes of the image. so i got error and cant
display the image. but can store it successfully.

plz help me and guide me its urgent

thanx
DataSet DST = new DataSet("MyPic");
byte[] Arr = new byte[0];
DataRow DRow;
SqlDataAdapter SDA = new SqlDataAdapter(SQLappend, Conn);
SqlCommandBuilder CBuild = new SqlCommandBuilder(SDA);
SDA.Fill(DST, "MyPic");

try
{
DRow = DST.Tables["MyPic"].Rows[0];

Arr = (byte[])DRow["ColumnWithPic"];
int ArraySize = new int();
ArraySize = Arr.GetUpperBound(0);
FileStream FStream = new FileStream(@"c:\MyPic.bmp",
FileMode.OpenOrCreate, FileAccess.Write);
FStream.Write(Arr, 0, ArraySize);
FStream.Close();FStream.Dispose();DRow.Delete();
}

Aug 16 '06 #2
SqlDataAdapter SDA = new SqlDataAdapter(SQLappend, Conn);

SQLappend = your select
Aug 16 '06 #3
Hi,

"Umar" <me************@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
hi

i am trying to store images in sql database in binary form .. i do it
.... but when i want to show that stored images on my web form any
where i got only first 16 bytes of the image. so i got error and cant
display the image. but can store it successfully.
How are you extracting the image from the DB?
I assume you are creating files for these extracted images right?
The way I do it is :
1- Check if the image is not already extracted, if so just return the path
2- Extract the image
3- Save it to disk to a dir for this purpose
4- return the link to the image file
Simple to implement,
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Aug 16 '06 #4

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

Similar topics

1
by: Rizyak | last post by:
Just when I though I knew what I was doing. I ran into a roadblock. I have two tables, organizations & users I am building a form online for orgs to input their own information. How do I...
3
by: | last post by:
Hi, I have a SQL Server database table where one of the columns is of type Image. The problem occurs when I try to retrieve images from the table. I'm using the following C# code: ...
1
by: loreille | last post by:
To insert a record in a Ms Access database and be able to retrieve the newly created ID (autonumber) I used the code below (code 1). Now, the problem is that this is not very secure and that, if...
0
by: dfetrow410 | last post by:
I am using a datalist. I need to retrieve only selected values. I tried to use the following code below with no luck. Not sure how to do the backend <tr> <td align="left" valign="top"><img...
0
by: yoyo | last post by:
DOes anybody have a working example of how do make this work? I've tried everything I could find, Clara patch, many non-working examples using pack, baseencode, addslashes, str_replace, bin2hex,...
0
by: m31hu1 | last post by:
Hi all, I'm new to this forum... I'm trying to let sql store data from a text file, but the data won't display... what am i missing here? Your help is greatly appreciated. create table <?php...
1
by: ahujasatna | last post by:
Hi all!! i am working on C#, ASP.Net with Sql server2000 and i am facing a problem, my Question is: "How to insert and retrieve images to/from Sqlserver2000 Database" I created a table...
1
by: sandraboy07 | last post by:
Hi, anyone. I have a problem with code php. I have image store in MS SQL Server and now i have a web code with php and i use MS SQL Server as datastore. I want to retrieve my image from DB or...
2
by: =?Utf-8?B?UGhpbGlw?= | last post by:
I am attempting to insert a simple record with LinqDataSource from a ListView, however I always get a message saying "....LinqDataSource 'dataSource' has no values to insert. Check that the...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.