-
Apr 28th, 2012, 07:55 AM
#1
Thread Starter
Member
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
-
Apr 28th, 2012, 09:13 AM
#2
Junior Member
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
-
Apr 28th, 2012, 09:20 AM
#3
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|