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

unlimited size for varbinary Sql Server 2005 parameter in C#

Hi

I am executing a Sql Server SP from my C# app
One of the parameters is of type varbinary. Since the content length of this
parameter is variable I cannot set it to a pre-defined length. What do I set
the parameter size to ?
I can set it to -1 but does -1 means variable upto maximum size of Varbinary
type ?

Regards
Dilip

Feb 26 '07 #1
5 8297
Random thought; you could set it to the size of the (runtime) data you
are adding? or alternaviely int.MaxValue?

If the data is huge, and you don't want to allocate a large byte[] in
your C#, then you may wish to chunk the transfer. For SELECT this is
easy enough using one of the DataReader overloads, however, for saves
you need (unless I have missed this option) to do it manually:

http://groups.google.com/group/micro...4e7e3782e59a93

Marc

Feb 26 '07 #2
dvarma wrote:
I am executing a Sql Server SP from my C# app
One of the parameters is of type varbinary. Since the content length of this
parameter is variable I cannot set it to a pre-defined length. What do I set
the parameter size to ?
I can set it to -1 but does -1 means variable upto maximum size of Varbinary
type ?
2000 : 8000
2005 : int.MaxValues

was obvious suggestions.

Arne
Feb 27 '07 #3
Actually, I believe that varbinary maps most closely to "image", so
was never subject to the 8000 page limit.

And (for the OP) another solution: simply don't set one! Not sure it
would be used for this data-type anyhows.

Marc

Feb 27 '07 #4
Marc Gravell wrote:
Actually, I believe that varbinary maps most closely to "image", so
was never subject to the 8000 page limit.
2000 BOL says:

varbinary [ ( n ) ]

Variable-length binary data of n bytes. n must be a value from 1 through
8,000.
2005 BOL says:

varbinary [ ( n | max) ]
Variable-length binary data. n can be a value from 1 through 8,000. max
indicates that the maximum storage size is 2^31-1 bytes.

So if the documentation can be trusted it was subject to the 8000 bytes
limit.

Arne
Feb 27 '07 #5
You are quite correct. I must have done a few too many translations
when reading it! So yes : if it is varbinary then you'd need to follow
the varbinary rules for that environment. I read it as "image" (hence
my comment), which can be added to SqlParamater using SqlDbType.Image,
but is a pain to do through IDbDataParameter and DbType.

Marc

Feb 28 '07 #6

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

Similar topics

8
by: Vinod | last post by:
Hi, I have a stored procedure which expects a varbinary datatype. How can i pass a varbinary datatype from asp.net directly to the stored procedure. I tried using the Convert function in Sql...
2
by: Dan | last post by:
I'm storing a byte array in a varbinary field in a SQL Server 2000 database, eg: dim b() as byte = new byte() {1,2,3,4} but when I attempt to retrieve the byte array (using...
4
by: Roy | last post by:
I have an object with array of some data types. How do I get the number of bytes for it in managed code? The underlying data types could be primitive types or userdefined structures. For example I...
2
by: Dominique | last post by:
Hello, Im want to fix the width of a dashboard. I have a field which has a field (in this dashboard on the left part of my screen) which could be long and make the right side of the screen out...
1
by: Karch | last post by:
I am doing some experimenting with serialization (for use with Service Broker) and I am having a problem converting from a .NET DateTime (in the client application) to a SqlDbType.VarBinary (as...
12
by: Light | last post by:
Hi all, I posted this question in the sqlserver.newusers group but I am not getting any response there so I am going to try it on the fine folks here:). I inherited some legacy ASP codes in my...
4
by: Martin Horst | last post by:
Hi, I've got an application which is written in .Net 1.1. When I try to write a varbinary(max) field using the SqlCommand and SqlParameter classes I got an exception like this: "The...
7
crystal2005
by: crystal2005 | last post by:
Hi everyone, I gonna ask how to set unlimited size of array of characters. According to the tutorial that i have found after amount of time of googling, array size should be defined when we...
1
by: quintonmartin | last post by:
Here's my problem. I have a client application that uses a web service for data access. I can read/update many records in many tables, however, I am not getting what I expect for a varbinary(max)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.