开发者

SqlDataReader.GetSqlBinary vs SqlDataReader.GetSqlBytes?

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?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜