SqlDataReader.GetSqlBinary vs SqlDataReader.GetSqlBytes?
Asked Answered
M

2

6

Under the namespace System.Data.SqlClient, we have both SqlDataReader.GetSqlBinary and SqlDataReader.GetSqlBytes.

Both seems to give "raw data". If so, what's the difference between them?

Manganite answered 21/7, 2011 at 11:20 Comment(0)
T
1

The GetSQLBytes are stored in an inside buffer for more manipulation, the Binary are just a stream that you get and use it as it is.

This two return SqlBytes and SqlBinary and by see this two types you can see the full different of them and how they store the data.

http://msdn.microsoft.com/en-us/library/system.data.sqltypes.sqlbytes.storage.aspx

http://msdn.microsoft.com/en-us/library/system.data.sqltypes.sqlbytes.aspx

Trothplight answered 21/7, 2011 at 11:27 Comment(0)
C
1

GetSqlBinary returns an SqlBinary structure:

Represents a variable-length stream of binary data to be stored in or retrieved from a database.

GetSqlBytes returns an SqlBytes class:

Represents a mutable reference type that wraps either a Buffer or a Stream.

So is seems that the difference is that GetSqlBinary gives you a lump of data as a byte array, while GetSqlBytes is similar but stores the data in a buffer which allows you to interact with the underlying data as a stream.

Courtly answered 21/7, 2011 at 11:27 Comment(0)
T
1

The GetSQLBytes are stored in an inside buffer for more manipulation, the Binary are just a stream that you get and use it as it is.

This two return SqlBytes and SqlBinary and by see this two types you can see the full different of them and how they store the data.

http://msdn.microsoft.com/en-us/library/system.data.sqltypes.sqlbytes.storage.aspx

http://msdn.microsoft.com/en-us/library/system.data.sqltypes.sqlbytes.aspx

Trothplight answered 21/7, 2011 at 11:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.