473,408 Members | 1,623 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,408 software developers and data experts.

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 7620

Get data from the database into binary array and calc in't length.
"Dino Buljubasic" <di**@noplacelikehome.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 #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****@vbstreets.ru>
wrote:

Get data from the database into binary array and calc in't length.
"Dino Buljubasic" <di**@noplacelikehome.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**@noplacelikehome.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**@noplacelikehome.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*@blockbuster.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**@noplacelikehome.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(imagecolumn) FROM sometable

"Dino Buljubasic" <di**@noplacelikehome.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 #9
WhatEverYourName 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.SqlConnection("Server=(local);" & _
"DataBase=Northwind; Integrated Security=SSPI")
Dim sqlstr1 As String = "SELECT DATALENGTH(Photo) " & _
" FROM Employees WHERE EmployeeID = 3"
Dim sqlstr2 As String = "SELECT Photo FROM Employees WHERE
EmployeeID = 3"
Dim cm As New SqlClient.SqlCommand(sqlstr1, conn)
conn.Open()
Console.Write(cm.ExecuteScalar.ToString & vbCrLf)
cm.CommandText = sqlstr2
Console.Write((DirectCast(cm.ExecuteScalar, 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
Look at using CommandBehavior.SequentialAccess along with DataReader.
"Cor Ligthert" <no************@planet.nl> wrote in message
news:e$**************@TK2MSFTNGP10.phx.gbl...
WhatEverYourName 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.SqlConnection("Server=(local);" & _
"DataBase=Northwind; Integrated Security=SSPI")
Dim sqlstr1 As String = "SELECT DATALENGTH(Photo) " & _
" FROM Employees WHERE EmployeeID = 3"
Dim sqlstr2 As String = "SELECT Photo FROM Employees WHERE
EmployeeID = 3"
Dim cm As New SqlClient.SqlCommand(sqlstr1, conn)
conn.Open()
Console.Write(cm.ExecuteScalar.ToString & vbCrLf)
cm.CommandText = sqlstr2
Console.Write((DirectCast(cm.ExecuteScalar, 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 #11
WhateverName,

Thanks

Cor
Nov 21 '05 #12
HI Cor,

thank you for your help. I fixed the problem and it works just great.
Did not know of DATALENGTH() before, now I learned something new

And it is working great.

I appreciate your help

On Thu, 10 Mar 2005 09:13:57 +0100, "Cor Ligthert"
<no************@planet.nl> wrote:
WhatEverYourName 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.SqlConnection("Server=(local);" & _
"DataBase=Northwind; Integrated Security=SSPI")
Dim sqlstr1 As String = "SELECT DATALENGTH(Photo) " & _
" FROM Employees WHERE EmployeeID = 3"
Dim sqlstr2 As String = "SELECT Photo FROM Employees WHERE
EmployeeID = 3"
Dim cm As New SqlClient.SqlCommand(sqlstr1, conn)
conn.Open()
Console.Write(cm.ExecuteScalar.ToString & vbCrLf)
cm.CommandText = sqlstr2
Console.Write((DirectCast(cm.ExecuteScalar, 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 #13
JD
You're welcome.

"Dino Buljubasic" <di**@noplacelikehome.com> wrote in message
news:5m********************************@4ax.com...
HI Cor,

thank you for your help. I fixed the problem and it works just great.
Did not know of DATALENGTH() before, now I learned something new

And it is working great.

I appreciate your help

On Thu, 10 Mar 2005 09:13:57 +0100, "Cor Ligthert"
<no************@planet.nl> wrote:
WhatEverYourName 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.SqlConnection("Server=(local);" & _
"DataBase=Northwind; Integrated Security=SSPI")
Dim sqlstr1 As String = "SELECT DATALENGTH(Photo) " & _
" FROM Employees WHERE EmployeeID = 3"
Dim sqlstr2 As String = "SELECT Photo FROM Employees WHERE
EmployeeID = 3"
Dim cm As New SqlClient.SqlCommand(sqlstr1, conn)
conn.Open()
Console.Write(cm.ExecuteScalar.ToString & vbCrLf)
cm.CommandText = sqlstr2
Console.Write((DirectCast(cm.ExecuteScalar, 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 #14

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

Similar topics

6
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...
4
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...
2
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...
5
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...
4
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...
3
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...
3
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,...
9
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...
1
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
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,...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.