472,371 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 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 7418

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
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.