Jump to content

'System.DBNull' ao tipo 'System.Byte[]


Recommended Posts

Não é possível associar o objecto de tipo 'System.DBNull' ao tipo 'System.Byte[]'.

   For i = 1 To Quantos
            'Abre a conexão
            Dim con As New System.Data.SqlClient.SqlConnection("Data Source=PORTATIL\SQLEXPRESS;Initial Catalog=BDReprografia;Integrated Security=True")
            'Faz o Select para obter as imagens
            Dim cmd As New System.Data.SqlClient.SqlCommand("select * from Produtos where CodProduto=" & i)
            cmd.Connection = con
            cmd.CommandType = CommandType.Text
            Dim da As New System.Data.SqlClient.SqlDataAdapter(cmd)
            Dim ds As New DataSet()
            'Conversão das imagens 

'--> ERROR AQUI            Dim bits As Byte() = CType(ds.Tables(0).Rows(0).Item(5), Byte())

            Dim memorybits As New MemoryStream(bits)
            Dim bitmap As New Bitmap(memorybits)
        Next i

Alguém me explica o porque disto ?

abraços e obrigado desde de já 🙂

Porque havia eu se assinar ? A minha mãe diz que é perigoso ter as nossas assinaturas na net ! :S

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.