Questions tagged [varbinarymax]

Variable-length binary data type in Microsoft SQL Server, where 'MAX' indicates that the data may hold up to the maximum storage size of 2^31-1 bytes.

142 questions
3
votes
1 answer

Set the DbParameter.DbType of a null value in a generic way?

I've got a problem with SQL update statements when I pass null values (or better let's say DbNull values) to a DbParameter object. When I pass the DbNull value to the Value property, the DbType of the DbParameter object is still STRING. If I try to…
msfanboy
  • 5,273
  • 13
  • 69
  • 120
3
votes
1 answer

Problem with STGeomCollFromWKB reading from varbinary(max)

I have imported a csv file containing spatial area information in varchar, then converted varchar(max) values to varbinary(max) by adding '0x' to varchar(max) values prior to conversion. By then, apart from the '0x' in the beginning, the data in…
Rez.Net
  • 1,354
  • 2
  • 19
  • 28
3
votes
1 answer

Assigning an empty binary value to a varbinary(MAX) column creates a column 8000 bytes long

I have a table with a varbinary(max) column, i am trying to assign to that column a zero-lengh binary buffer, but instead of getting a zero-length value in the table, i am getting an 8000 bytes long value filled with zeros: * the dataSize column in…
Amit Bens
  • 1,315
  • 3
  • 12
  • 20
3
votes
4 answers

How to specify EF byte[] in code first longer than 8000 bytes?

I am using EF 6.1.3. Using code first sets a byte[] property in an entity to max. 8000 bytes. Any attempt to make it greater, that is MAX, fails. HasMaxLength(null) (yes, the parameter is int?) still sets it to 8000, HasMaxLength(int.MaxValue) or…
Alexander Christov
  • 9,625
  • 7
  • 43
  • 58
3
votes
3 answers

How can I search for a sequence of bytes in SQL Server varbinary(max) field?

I am trying to write a query on SQL Server 2012 that will return varbinary(max) columns that contain a specified byte sequence. I am able to do that with a query that converts the varbinary field to varchar and uses LIKE: SELECT * FROM foo WHERE…
Dan Hermann
  • 1,107
  • 1
  • 13
  • 27
3
votes
1 answer

Checking if a varbinary(max) column is null is really slow

When I try to run the following query (or even try to get the estimated execution plan), it is very slow, 10+ minutes (I stopped waiting): SELECT TOP 1 1 FROM File WITH (NOLOCK) WHERE FileID = '5021ECD3-2012-62E0-1F12-000041CCB35A' AND…
Kevin Doyon
  • 3,464
  • 2
  • 33
  • 38
2
votes
1 answer

WPF - Convert file to Byte[] to BitmapSource using JpegBitmapDecoder

I need to read a jpg file and latyer display it in an Image controll. The following works perfectly: imgTwo.Source = FetchImage(@"C:\Image075.jpg"); public BitmapSource FetchImage(string URLlink) { JpegBitmapDecoder decoder = null; …
Keren
  • 81
  • 2
  • 10
2
votes
1 answer

Returning stream from an open DbConnection on WebApi: close connection when ending

I'm reading a varbinary(max) field from a SQL database as a Stream... and I want to return that stream as a file. I'm using EF Core, however EF Core mapping requires (or I don't know better) to map varbinary fields to byte arrays, and that means…
Jcl
  • 27,696
  • 5
  • 61
  • 92
2
votes
0 answers

grabbing the bytes from the mid point of an image stored in varbinary field and determining HTMLColor

Here is a primary example: I have a varbinary field in sql server that stores and image. I need to determine the middle of the image grab the 4 digit byte and use that to determine the color. I have no idea how I determine what to look at in that…
2
votes
1 answer

Problem inserting binary data through SQL query (SQL Server 2008)

These is the query i have found for inserting binary data (using varbinary) which is working perfectly CREATE TABLE Employees ( Id int, Name varchar(50) not null, Photo varbinary(max) not null ) INSERT INTO Employees (Id, Name,…
user646093
  • 1,495
  • 3
  • 15
  • 20
2
votes
1 answer

Using 'request' in node to download image from URL as buffer and then insert into SQL database as varbinary(max)

I'm authenticating users with google/facebook/ms Oauth and I'm then giving them a refresh token. I then use this long-lived refresh token to make requests for short-lived access tokens. The issue I'm having is my app uses the social profile's photo…
SebastianG
  • 8,563
  • 8
  • 47
  • 111
2
votes
1 answer

Is there a tool to load files into varbinary(max) fields?

I was contemplating the creation of a tool to load varbinary(max) fields in a SQL Server 2008 database with files as selected from a open file dialog. Is there any such tool or equivalent that I could use? My SQL server is in a hosted environment…
Matt Ruwe
  • 3,386
  • 6
  • 39
  • 77
2
votes
1 answer

SqlDataReader: Read varbinary into byte array

I have a SQL Server table with a varbinary(max) column. I use it to store images in it. The images are selected with an OpenFileDialog, translated into a byte[] like this public byte[] ConvertImageToByteArray(String filepath) { try { …
farosch
  • 210
  • 4
  • 16
2
votes
1 answer

Reading 200MB file from db throws Out Of Memory Exception

I am attempting to query the database and pull excel files that could be as large as 1 million rows (~200MB) stored as varbinary and pass it through a validator. Our build server has 6GB of memory and a load-balanced processor and during runtime…
Nathan Foss
  • 595
  • 1
  • 9
  • 34
2
votes
1 answer

Photos as Varbinary(MAX) in SQL Server 2012 causes error 502753 in Access 2010

I have an Access 2010 odbc front end with a SQL Server 2012 back end. My images (.bmp) are stored as Varbinary(Max). When I insert an image using my bound object frame in an Access form, the image displays on the form and report perfectly. I had a…
1
2
3
9 10