把简单的事情做好
直接在SQL查询将Image类型的字段转为Base64字符串。
1234
DECLARE @img1 VARBINARY ( max ) SELECT @img1 = ImageCol FROM xxx WHERE col = '12159' SELECT *, CAST( '' AS XML ).value( 'xs:base64Binary(sql:variable("@img1"))', 'VARCHAR(MAX)' ) AS img1 FROM xxx WHERE col = '12159'
OR
select base64from xxxcross apply (select ImageCol as '*' for xml path('')) T (base64)where col = '12159'