473,382 Members | 1,202 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.

questioni about SqlBytes class

I have the following code

System.Data.SqlTypes.SqlBytes bytes = reader.GetSqlBytes(columnIndex);
MemoryStream ms = new MemoryStream(bytes.Buffer);

My question is will the Buffer property of SqlBytes reliable get all the
data from the bytes retreived from the GetSqlBytes function. It seems to do
so in my testing but will this always be the case. The documentation is a bit
sparse on this. It was the only way I could find to populate a memory stream
from the SqlBytes.

--
Scott
Mar 29 '07 #1
5 3475
What bother you really?? If it is working alright

Nirosh.

"scottrm" <sc*****@newsgroup.nospamwrote in message
news:35**********************************@microsof t.com...
>I have the following code

System.Data.SqlTypes.SqlBytes bytes = reader.GetSqlBytes(columnIndex);
MemoryStream ms = new MemoryStream(bytes.Buffer);

My question is will the Buffer property of SqlBytes reliable get all the
data from the bytes retreived from the GetSqlBytes function. It seems to
do
so in my testing but will this always be the case. The documentation is a
bit
sparse on this. It was the only way I could find to populate a memory
stream
from the SqlBytes.

--
Scott

Mar 29 '07 #2
What bother you really?? If it is working alright
>
Because it might be working just in the cases he has tested and could maybe
still fail in a "real life" situation.
So he (rightfully) wants documentation that states that it will always behave
this way.

Hans Kesting
Mar 29 '07 #3
Your test cases indeed should cover the real life situation, else what is
the point of that test??

Nirosh.

"Hans Kesting" <ne***********@spamgourmet.comwrote in message
news:c0*************************@news.microsoft.co m...
>What bother you really?? If it is working alright

Because it might be working just in the cases he has tested and could
maybe still fail in a "real life" situation.
So he (rightfully) wants documentation that states that it will always
behave this way.

Hans Kesting


Mar 29 '07 #4
Scott,

Unless you have to manupulate the values of the bytes, you should just
call the Stream property on the SqlBytes instance. This will return a
stream of bytes that taps into the TDS stream that SQL Server returns. If
you call the Buffer property, it will read the entire contents of the stream
into memory. It's not the MemoryStream that is helping you, it is the call
to Buffer.

As for will it always be reliable? Well, no, but that's the nature of
things. Any number of things could go wrong. What if someone pulls the
network cord while reading the contents from the stream?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"scottrm" <sc*****@newsgroup.nospamwrote in message
news:35**********************************@microsof t.com...
>I have the following code

System.Data.SqlTypes.SqlBytes bytes = reader.GetSqlBytes(columnIndex);
MemoryStream ms = new MemoryStream(bytes.Buffer);

My question is will the Buffer property of SqlBytes reliable get all the
data from the bytes retreived from the GetSqlBytes function. It seems to
do
so in my testing but will this always be the case. The documentation is a
bit
sparse on this. It was the only way I could find to populate a memory
stream
from the SqlBytes.

--
Scott

Mar 29 '07 #5
Your test cases indeed should cover the real life situation, else what
is the point of that test??

Nirosh.
Maybe I should have said "*unforseen* real life situation". You can only test
against situations that you expect.

And if the docs state "it will always behave like this", you don't have to
test
that against every imaginable situation.

Hans Kesting
Mar 30 '07 #6

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

Similar topics

8
by: Fu Bo Xia | last post by:
the java.lang.Object.forName method takes a java class name and returns a Class object associated with that class. eg. Class myClass = Object.forName("java.lang.String"); by if i only know the...
1
by: Murat Tasan | last post by:
hi, i am having a small problem with constructing an inner class. i am using an inner class (and not a static nested class) because the methods of the inner class need access to the enclosing...
2
by: Ovid | last post by:
Hi, I'm trying to determine the cleanest way to override class data in a subclass. class Universe { public String name; private static double PI = 3.1415; Universe(String name) {
7
by: Kerry Neilson | last post by:
Hi, Really hung up on this one. I'm trying to get all the fields of a dictionary to be unique for each class: class A { my_dict = dict_entry = { 'key1':0, 'key2':0 } __init__(self): for...
2
by: Fernando Rodriguez | last post by:
Hi, I need to traverse the methods defined in a class and its superclasses. This is the code I'm using: # An instance of class B should be able to check all the methods defined in B #and A,...
2
by: Gabriel Genellina | last post by:
Hi In the following code sample, I have: - a Worker class, which could have a lot of methods and attributes. In particular, it has a 'bar' attribute. This class can be modified as needed. - a...
1
by: Stefan Seefeld | last post by:
hi there, I'v run into a little problem for which I only found an ugly workaround, so I'd like to know whether people are aware of better ways to achieve this... I'm defining a class 'Class'...
12
by: Gaurav Veda | last post by:
Hi ! I am a poor mortal who has become terrified of Python. It seems to have thrown all the OO concepts out of the window. Penniless, I ask a basic question : What is the difference between a...
3
by: Hamilton Woods | last post by:
Diehards, I developed a template matrix class back around 1992 using Borland C++ 4.5 (ancestor of C++ Builder) and haven't touched it until a few days ago. I pulled it from the freezer and...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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.