Pages

Thursday 9 August 2012

Simpan Image mySql With File Upload


 Dim img As FileUpload = CType(FileUpload1, FileUpload)
                Dim imgByte As Byte() = Nothing
                If img.HasFile AndAlso Not img.PostedFile Is Nothing Then
                    'To create a PostedFile
                    Dim File As HttpPostedFile = FileUpload1.PostedFile
                    'Create byte Array with file len
                    imgByte = New Byte(File.ContentLength - 1) {}
                    'force the control to load data in array
                    File.InputStream.Read(imgByte, 0, File.ContentLength)
                    cmd.CommandText = "update daftar_siswa  set fotosiswa=@img where id_pendaftaran='" & ASPxTextBox1.Text & "'"
                    cmd.Parameters.AddWithValue("@img", imgByte) : cmd.Connection = con
                    cmd.ExecuteNonQuery()
                End If

Ayo DI coba Brow !00% Berhasil...


No comments:

Post a Comment