473,708 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get size of an file stored as image in SQL Database

I want to get the size of a file stored in SQL Database (as image data
type).

Anybody knows how to do this?

Any help will be greatelly appreciated
Nov 21 '05 #1
13 7679

Get data from the database into binary array and calc in't length.
"Dino Buljubasic" <di**@noplaceli kehome.com> wrote in message
news:74******** *************** *********@4ax.c om...
I want to get the size of a file stored in SQL Database (as image data
type).

Anybody knows how to do this?

Any help will be greatelly appreciated

Nov 21 '05 #2

No I can not do that. I need the size of image so I can set my
progress bar so it displays how much of that image has been downloaded
so far. If I store it ino an array, then what is point of having
progress bar, the image is already fetched from the database.

On Wed, 9 Mar 2005 22:12:53 +0300, "gaidar" <ga****@vbstree ts.ru>
wrote:

Get data from the database into binary array and calc in't length.
"Dino Buljubasic" <di**@noplaceli kehome.com> wrote in message
news:74******* *************** **********@4ax. com...
I want to get the size of a file stored in SQL Database (as image data
type).

Anybody knows how to do this?

Any help will be greatelly appreciated


Nov 21 '05 #3
just to correct my self:

I need this information so I can set my progress bar to show download
progress.

Thank you

On Wed, 09 Mar 2005 18:47:53 GMT, Dino Buljubasic
<di**@noplaceli kehome.com> wrote:
I want to get the size of a file stored in SQL Database (as image data
type).

Anybody knows how to do this?

Any help will be greatelly appreciated


Nov 21 '05 #4
Dino Buljubasic wrote:
just to correct my self:

I need this information so I can set my progress bar to show download
progress.

Thank you

On Wed, 09 Mar 2005 18:47:53 GMT, Dino Buljubasic
<di**@noplaceli kehome.com> wrote:

I want to get the size of a file stored in SQL Database (as image data
type).

Anybody knows how to do this?

Any help will be greatelly appreciated


Then store the size of the file in the database.

Bob
Nov 21 '05 #5
Dino,

You make me curious, I know that I can get an image from a database using a
datareader, using an executescalar, using a dataadapter.

Non of those give me the change to see any progress even when I know how
large the image is.

How do you do that?

Cor
Nov 21 '05 #6
I really appreciate help but I don't need help on how to go arround
the problem but how to solve it.

I can not store size to the database because database already exist
with thousants of records in it. I am not in the position to go
throught every record find sizes of images and update the database.

thank you

On Wed, 09 Mar 2005 20:33:48 +0100, Bob Hollness <bo*@blockbuste r.com>
wrote:
Dino Buljubasic wrote:
just to correct my self:

I need this information so I can set my progress bar to show download
progress.

Thank you

On Wed, 09 Mar 2005 18:47:53 GMT, Dino Buljubasic
<di**@noplaceli kehome.com> wrote:

I want to get the size of a file stored in SQL Database (as image data
type).

Anybody knows how to do this?

Any help will be greatelly appreciated


Then store the size of the file in the database.

Bob


Nov 21 '05 #7

I am using FileStream and BinaryWriter to load the image and write it
to a byte array.

I write chunks of binary data to array in a while loop. At the end I
can get the size of that array but I need the size before I start
downloading it so I can calculate progress inside my progress bar.

Unfortunatelly, creators of the database did not store size of images
saved to database in a column, so I can not fetch that information.

Any Ideas how to solve this?

Thank you, appreciate your help

On Wed, 9 Mar 2005 20:35:50 +0100, "Cor Ligthert"
<no************ @planet.nl> wrote:
Dino,

You make me curious, I know that I can get an image from a database using a
datareader, using an executescalar, using a dataadapter.

Non of those give me the change to see any progress even when I know how
large the image is.

How do you do that?

Cor


Nov 21 '05 #8
SELECT DATALENGTH(imag ecolumn) FROM sometable

"Dino Buljubasic" <di**@noplaceli kehome.com> wrote in message
news:74******** *************** *********@4ax.c om...
I want to get the size of a file stored in SQL Database (as image data
type).

Anybody knows how to do this?

Any help will be greatelly appreciated

Nov 21 '05 #9
WhatEverYourNam e is,

I made a piece of code (sample) from your SQLString which test it direct.

\\\
Public Class TestLength
Public Shared Sub Main()
Dim conn As New SqlClient.SqlCo nnection("Serve r=(local);" & _
"DataBase=North wind; Integrated Security=SSPI")
Dim sqlstr1 As String = "SELECT DATALENGTH(Phot o) " & _
" FROM Employees WHERE EmployeeID = 3"
Dim sqlstr2 As String = "SELECT Photo FROM Employees WHERE
EmployeeID = 3"
Dim cm As New SqlClient.SqlCo mmand(sqlstr1, conn)
conn.Open()
Console.Write(c m.ExecuteScalar .ToString & vbCrLf)
cm.CommandText = sqlstr2
Console.Write(( DirectCast(cm.E xecuteScalar, Byte()).Length) .ToString
& vbCrLf)
conn.Close()
End Sub
End Class
///

Now I still needs to know how Dino does the reading.

Cor
Nov 21 '05 #10

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

Similar topics

6
2236
by: Pierre-Benoit | last post by:
Hi there, I've a strange problem with ado.net and an Access db. I need to create a little C# app that take the content of "ole object" field and then save it into a file. The problem is that when I do the following Byte byteBLOBData = new Byte; byteBLOBData = (Byte)(ds.Tables.Rows);
4
7623
by: Andy | last post by:
Hello All: I have a field in the database that is an Image. I have no idea how the data is stored in here (Image, compressed, encrypted, plain text, etc). I am trying to write the contents to a text file, image file, etc so I can see if the data is stored in a way we can understand (we have been tasked to write an app and the app needs to read this field, but we don't know what it really contains). How would I go about reading the...
2
3108
by: Mike | last post by:
I running MySQL locally and have the following dir setup C:\wamp\mysql\data\mike - This is where the tables for the database mike are stored C:\wamp\mysql\data - This is where I think the database data is stored. Basically the file in the data dir. (ibdata1) is 10,240kb in size. When I update a table in the mike database the file size of ibdata1 doesn't increase and I don't know why?
5
5434
by: Philippe Martin | last post by:
Hi, Thanks to the NG, I got the script hereunder working. 1) I am not certain that the call to convert does much (checking the doc) 2) Can this be improved as far as the final image size in (X,Y) ? For instance, passing a large .jpg with a target byte size of 7000, I get final (X,Y) results around (213, 174) ... but might want to strech it a bit
4
1073
by: Jarry | last post by:
What are the rules on how VB.Net 2005 packages graphics? If I use the same graphic in two different picture boxes, does both the images count towards the final size? What if I start with image really small and then stretch it to fit the picture box? Is it woth just using colours if I want to keep file sizes down? Do the grahics make any difference to the exe file size anyway? So many questions, so little time. Any help whatsoever would...
3
2959
by: =?Utf-8?B?ZGF2aWQ=?= | last post by:
I try to follow Steve's paper to build a database, and store a small text file into SQL Server database and retrieve it later. Only difference between my table and Steve's table is that I use NTEXT datatype for the file instead of using IMAGE datatype. I can not use SqlDataReader to read the data. I need your help, Thanks. -David (1) I have a table TestFile for testing: ID int FileName navrchar(255)
3
12985
by: Christoph Burschka | last post by:
Is there some way to get the dimensions of an image, given the binary data of the image, without having to write it to a temporary file? It seems that getimagesize() will only take a filename, but since I have to download the image from a remote URL with fsockopen(), I have it stored as a binary string. I've had a cursory glance at the data, but predictably the size is not stored in decimal format anywhere...
9
4190
by: shailajaAdiga | last post by:
Hi All.. images are stored in database(imagecontent and image type is stored).Currently i have displayed the image in popup window (no size limits to window). I would like to get the image size and display accordingly. is it possible to get image size if i retireve imagecontent from databse? Please anyone help me out. Thanks..
1
2932
by: RYKLOU | last post by:
I am kinda new to php, but i do know what i am doing kinda, but i came across this error when i am trying to upload a file to my website. Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 3714000 bytes) in /opt/lampp/htdocs/tutorials/php-mysql-tutorial/admin/image-gallery/library/functions.php on line 104 Platform: Ubuntu 8.04 LST (where i make my programs, and test them before i upload them), Using XAMPP for...
0
8788
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8697
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7925
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4454
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2508
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2097
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.