473,795 Members | 2,746 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
13 7690
Look at using CommandBehavior .SequentialAcce ss along with DataReader.
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:e$******** ******@TK2MSFTN GP10.phx.gbl...
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 #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:
WhatEverYourNa me 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 #13
JD
You're welcome.

"Dino Buljubasic" <di**@noplaceli kehome.com> wrote in message
news:5m******** *************** *********@4ax.c om...
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:
WhatEverYourNa me 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 #14

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

Similar topics

6
2239
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
7626
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
3114
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
5438
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
1074
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
2961
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
12991
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
4194
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
2937
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
9672
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
9519
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,...
0
10436
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10163
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
9040
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
7538
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
5436
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...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.