Results 1 to 3 of 3

Thread: delete a row in sql server with image column

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2012
    Posts
    33

    delete a row in sql server with image column

    Hi,

    Just wonder how can i delete an entire row at once in sql server database including images and textfields.

    i mean, if i have an update button for inserting images and i have got another navigator which adds information to the database, how could i delete a selected row in sql server database...

    In dataset, i used to remove a specific row in database by doing:

    me.customersbindingsource.removecurrent()
    So, this one doesn't delete anything when the image is included.

    1.
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
    2.
    Dim pictureLocation As String
    3.
    Dim a As New OpenFileDialog
    4.
    a.Filter = ("Image files| *.jpg")
    5.
    pictureLocation = a.FileName
    6.
    a.ShowDialog()
    7.
    Using conn As New System.Data.SqlClient.SqlConnection("Data Source=MUSTAFA\MUSTAFA;Initial Catalog=TestMe;User ID=sa;Password=123")
    8.
    conn.Open()
    9.
    Using cmd As New SqlClient.SqlCommand("update customers set picturem=@picturem ", conn)
    10.
    cmd.Parameters.Add(New SqlClient.SqlParameter("@picturem", SqlDbType.VarBinary)).Value = IO.File.ReadAllBytes(a.FileName)
    11.
    cmd.ExecuteNonQuery()
    12.
    End Using
    13.
    End Using
    14.
    End Sub


    Regards,
    Hossy

  2. #2
    Junior Member
    Join Date
    Nov 2010
    Posts
    30

    Re: delete a row in sql server with image column

    just for the heck of it, are you using an image type column or a varbinary(max)? I've had better luck with the varbinary(max), you can compare varbinarys but images you can't as far as i know, and with sql 2005

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2012
    Posts
    33

    Re: delete a row in sql server with image column

    Hi,

    Am using image column data type as varbinary(max)...I guess i can delete it by using data set navigator toolbar then save your change but not quite sure if it will delete it perfectly.

    Regards,
    Hossy

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