当前位置: 动力学知识库 > 问答 > 编程问答 >

VB.Net Convert Byte Array to SQLBinary

问题描述:

I Searched and searched and found no clear answer to this problem.

How to convert array byte to SQLBinary.

I've tried with Narrowing/Widening Operators but nothing seems to work...

Public Shared Widening Operator CType(ByVal p1 As Byte()) As SQLBinary

End Operator

This throws an error: Error 8 Either the parameter type or the return type of this conversion operator must be of the containing type 'reportManager'. reportManager.ascx.vb 12 37

So how do I go around this and create a function of the sorts that can convert this properly?

网友答案:

Just pass the Byte Array into the constructor:

    Dim objSqlBinary As New System.Data.SqlTypes.SqlBinary(myByteArray)

Widening CType Operators require that the class that you define them in be either the return type or what gets converted. I'm assuming you defined that operator in your reportManager.ascx.vb file, which is why its looking for reportManager.

分享给朋友:
您可能感兴趣的文章:
随机阅读: