Update and Delete images from sqlserver2000 (vb.net 2005)
-
how to update and delete images from sqlserver2000 using vb.net, please help me.. this my code this code for search an image, i made some button for search image cz i want insert many image in one click button save, and its work :
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim picturelocation As String
a.Filter = "(*.jpg)|*.jpg|(*.bmp)|*.bmp|(*.pdf)|*.pdf|All files (*.*)|*.*"
picturelocation = a.FileName
Try
If a.ShowDialog = Windows.Forms.DialogResult.OK Then
'PictureBox1.Image = New Bitmap(a.FileName)
TextBox7.Text = a.FileName
'PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End If
Button6.Focus()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information)
End Try
End Suband this code for my button save n its work :
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
Try
If TextBox5.Text = "" Or TextBox6.Text = "" Then
MsgBox("Lengkapi", MsgBoxStyle.Critical)
If TextBox5.Text = "" Then
TextBox5.Focus()
ElseIf TextBox6.Text = "" Then
TextBox6.Focus()
ElseIf TextBox7.Text = "" Then
Button5.Focus()
End If
Else
Call koneksi()
cmd = New SqlCommand("select * from tabel_karyawan where kode_karyawan='" & TextBox4.Text & "'", conn)
rd = cmd.ExecuteReader
rd.Read()
If Not rd.HasRows Then
If TextBox7.Text = "" And TextBox8.Text = "" And TextBox9.Text = "" And TextBox10.Text = "" And TextBox11.Text = "" And TextBox12.Text = "" Then
Call koneksi()
Using sql As New SqlClient.SqlCommand("insert into tabel_karyawan(kode_karyawan,nama_karyawan,nomor_ktp)values(@kode_karyawan,@nama_karyawan,@nomor_ktp)", conn)
sql.Parameters.Add(New SqlClient.SqlParameter("@kode_karyawan", SqlDbType.Char)).Value = TextBox4.Text
sql.Parameters.Add(New SqlClient.SqlParameter("@nama_karyawan", SqlDbType.VarChar)).Value = TextBox5.Text
sql.Parameters.Add(New SqlClient.SqlParameter("@nomor_ktp", SqlDbType.V -
how to update and delete images from sqlserver2000 using vb.net, please help me.. this my code this code for search an image, i made some button for search image cz i want insert many image in one click button save, and its work :
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim picturelocation As String
a.Filter = "(*.jpg)|*.jpg|(*.bmp)|*.bmp|(*.pdf)|*.pdf|All files (*.*)|*.*"
picturelocation = a.FileName
Try
If a.ShowDialog = Windows.Forms.DialogResult.OK Then
'PictureBox1.Image = New Bitmap(a.FileName)
TextBox7.Text = a.FileName
'PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End If
Button6.Focus()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information)
End Try
End Suband this code for my button save n its work :
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
Try
If TextBox5.Text = "" Or TextBox6.Text = "" Then
MsgBox("Lengkapi", MsgBoxStyle.Critical)
If TextBox5.Text = "" Then
TextBox5.Focus()
ElseIf TextBox6.Text = "" Then
TextBox6.Focus()
ElseIf TextBox7.Text = "" Then
Button5.Focus()
End If
Else
Call koneksi()
cmd = New SqlCommand("select * from tabel_karyawan where kode_karyawan='" & TextBox4.Text & "'", conn)
rd = cmd.ExecuteReader
rd.Read()
If Not rd.HasRows Then
If TextBox7.Text = "" And TextBox8.Text = "" And TextBox9.Text = "" And TextBox10.Text = "" And TextBox11.Text = "" And TextBox12.Text = "" Then
Call koneksi()
Using sql As New SqlClient.SqlCommand("insert into tabel_karyawan(kode_karyawan,nama_karyawan,nomor_ktp)values(@kode_karyawan,@nama_karyawan,@nomor_ktp)", conn)
sql.Parameters.Add(New SqlClient.SqlParameter("@kode_karyawan", SqlDbType.Char)).Value = TextBox4.Text
sql.Parameters.Add(New SqlClient.SqlParameter("@nama_karyawan", SqlDbType.VarChar)).Value = TextBox5.Text
sql.Parameters.Add(New SqlClient.SqlParameter("@nomor_ktp", SqlDbType.Vimam_hatake wrote:
New SqlCommand("select * from tabel_karyawan where kode_karyawan='" & TextBox4.Text & "'", conn)
Start by reading about SQL Injection[^], and then fixing all of your vulnerable queries. For example, in the query above, what do you think will happen if the user types the following into
TextBox4
?'; DELETE FROM tabel_karyawan;--
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer