Results 1 to 3 of 3

Thread: [RESOLVED] check whether image at dataset is empty or not

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2008
    Posts
    45

    Resolved [RESOLVED] check whether image at dataset is empty or not

    im getting a image from my database to a data set. before i convert it to a proper picture i need to check whether ds.Tables("userDetails").Rows(0).Item("photo") is EMPTY or NOT. How should i write the if condition?


    <code>If ds.Tables("userDetails").Rows(0).Item("photo")<> ??? Then


    Dim pictureData As Byte() = DirectCast(ds.Tables("userDetails").Rows(0).Item("photo"), Byte())

    Dim picture As Image = Nothing

    Using stream As New IO.MemoryStream(pictureData)
    picture = Image.FromStream(stream)
    End Using

    PictureBox2.Image = picture
    Else
    MsgBox("No picture")
    End If</code>

    I tried as follows.

    <code>If ds.Tables("userDetails").Rows(0).Item("photo")<> DBNullThen</code>


    <code>If ds.Tables("userDetails").Rows(0).Item("photo")<> System.DBNullThen</code>

    But didnt work. PLZ help! thanks

  2. #2

    Thread Starter
    Member
    Join Date
    Oct 2008
    Posts
    45

    Re: check whether image at dataset is empty or not

    Sorry i forgot to say: Im using Visual Studio 2005 & using Microsoft SQL Server Database (Express)

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2008
    Posts
    45

    Re: check whether image at dataset is empty or not

    found by myself the answer.

    <code> If Not IsDBNull(ds.Tables("userDetails").Rows(0).Item("photo")) Then <\code>


    is the answer for my question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width