GRAVAR FOTO NO BD
Bom dia amigos.
Tenho um cadastro de alunos com foto. Gostaria de saber como gravar na tabela, no campo foto, a imagem que está numa PictureBox?
Por exemoplo, eu abro o cadastro digito os dados e seleciono uma imagem para inserir numa PictureBox. AÃ, na hora de salvar, vou salvar o caminho da pasta que contém as fotos e o nome da foto que foi escolhida. Como pegar o nome da imagem e gravar na tabela?
Até mais.
Tenho um cadastro de alunos com foto. Gostaria de saber como gravar na tabela, no campo foto, a imagem que está numa PictureBox?
Por exemoplo, eu abro o cadastro digito os dados e seleciono uma imagem para inserir numa PictureBox. AÃ, na hora de salvar, vou salvar o caminho da pasta que contém as fotos e o nome da foto que foi escolhida. Como pegar o nome da imagem e gravar na tabela?
Até mais.
amigo me add no msn m_hds23@hotmail.com
te passo todo o codigo
load
[ô]webcam
Inherits System.Windows.Forms.Form
Private Declare Function capCreateCaptureWindow Lib [Ô]avicap32.dll[Ô] Alias [Ô]capCreateCaptureWindowA[Ô] (ByVal lpszWindowName As String, ByVal dwStyle As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hwndParent As Integer, ByVal nID As Integer) As Integer
[ô]UPGRADE_ISSUE: Declaring a parameter [ô]As Any[ô] is not supported. Click for more: [ô]ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword=[Ô]FAE78A8D-8978-4FD4-8208-5B7324A8F795[Ô][ô]
Private Declare Function SendMessage Lib [Ô]USER32[Ô] Alias [Ô]SendMessageA[Ô] (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer) As Integer
Private Declare Function ReleaseCapture Lib [Ô]USER32[Ô] () As Integer
Private Const WM_CAP_DRIVER_CONNECT As Integer = 1034
Private Const WM_CAP_DRIVER_DISCONNECT As Integer = 1035
Private Const WM_CAP_GRAB_FRAME As Integer = 1084
Private Const WM_CAP_EDIT_COPY As Integer = 1054
Private Const WM_CAP_DLG_VIDEOFORMAT As Integer = 1065
Private Const WM_CAP_DLG_VIDEOSOURCE As Integer = 1066
Private Const WM_CLOSE As Integer = &H10
Private mCapHwnd As Integer
[ô]tirar foto
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
[ô]Tirar Foto[ô]
My.Computer.Clipboard.Clear()
SendMessage(mCapHwnd, WM_CAP_GRAB_FRAME, 0)
SendMessage(mCapHwnd, WM_CAP_EDIT_COPY, 0)
Picture1.Image = My.Computer.Clipboard.GetImage()
Timer1.Enabled = False
Timer1.Interval = 50
Dim destino As String
Dim novonome As String
destino = [Ô]C:\Diet\diet\Fotos\[Ô]
novonome = IdTextBox.Text + [Ô].[Ô] + TextBox2.Text + [Ô].jpeg[Ô]
TXTDESTINO.Text = destino & novonome
Button4.Enabled = True
Button3.Enabled = True
[ô]nova foto
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
[ô]Nova Foto[ô]
TXTDESTINO.Text = [Ô][Ô]
SendMessage(mCapHwnd, WM_CAP_DRIVER_DISCONNECT, 0)
mCapHwnd = capCreateCaptureWindow([Ô]captura Janela[Ô], 0, 0, 0, 320, 240, Me.Handle.ToInt32, 0)
SendMessage(mCapHwnd, WM_CAP_DRIVER_CONNECT, 0)
Timer1.Enabled = True
Timer1.Interval = 50
[ô]salvar foto
Public Sub salvar_foto()
Dim dados As IDataObject
Dim bmap As Image
[ô] Copia a imagem para o clipboard
SendMessage(mCapHwnd, WM_CAP_EDIT_COPY, 0)
[ô] Obtem a imagem do clipboard e converte para bitmap
dados = Clipboard.GetDataObject()
If dados.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
bmap = CType(dados.GetData(GetType(System.Drawing.Bitmap)), Image)
Picture1.Image = bmap
bmap.Save(TXTDESTINO.Text)
[ô] If sfdimage.ShowDialog = System.Windows.Forms.DialogResult.OK Then
[ô]bmap.Save(sfdimage.FileName, Imaging.ImageFormat.Jpeg)
[ô] End If
End If
Timer1.Enabled = False
Timer1.Interval = 50
[ô] MessageBox.Show([Ô]FOTO SALVA COM SUCESSO[Ô])
Button5.Enabled = True
Button2.Enabled = False
Button3.Enabled = True
Button4.Enabled = False
[ô]ligar webcam
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
SendMessage(mCapHwnd, WM_CAP_GRAB_FRAME, 0)
SendMessage(mCapHwnd, WM_CAP_EDIT_COPY, 0)
Picture1.Image = My.Computer.Clipboard.GetImage()
End Sub
Button2.Enabled = True
End Sub
[ô]desligar webcam
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
[ô]Desliga a câmera
SendMessage(mCapHwnd, WM_CAP_DRIVER_DISCONNECT, 0)
[ô] MsgBox([Ô]!!!SE VOCE JA TIROU A FOTO VOLTE PARA TELA DE CADASTRO E CARREGUE A FOTO!!![Ô])
[ô]Picture1.Image.Dispose()
Button1.Enabled = True
Picture1.Image = Picture1.InitialImage
TXTDESTINO.Text = [Ô][Ô]
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
[ô]Exibe imagem continua no pictubox
My.Computer.Clipboard.Clear()
SendMessage(mCapHwnd, WM_CAP_GRAB_FRAME, 0)
SendMessage(mCapHwnd, WM_CAP_EDIT_COPY, 0)
Picture1.Image = My.Computer.Clipboard.GetImage()
System.Windows.Forms.Application.DoEvents()
End Sub
te passo todo o codigo
load
[ô]webcam
Inherits System.Windows.Forms.Form
Private Declare Function capCreateCaptureWindow Lib [Ô]avicap32.dll[Ô] Alias [Ô]capCreateCaptureWindowA[Ô] (ByVal lpszWindowName As String, ByVal dwStyle As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hwndParent As Integer, ByVal nID As Integer) As Integer
[ô]UPGRADE_ISSUE: Declaring a parameter [ô]As Any[ô] is not supported. Click for more: [ô]ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword=[Ô]FAE78A8D-8978-4FD4-8208-5B7324A8F795[Ô][ô]
Private Declare Function SendMessage Lib [Ô]USER32[Ô] Alias [Ô]SendMessageA[Ô] (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer) As Integer
Private Declare Function ReleaseCapture Lib [Ô]USER32[Ô] () As Integer
Private Const WM_CAP_DRIVER_CONNECT As Integer = 1034
Private Const WM_CAP_DRIVER_DISCONNECT As Integer = 1035
Private Const WM_CAP_GRAB_FRAME As Integer = 1084
Private Const WM_CAP_EDIT_COPY As Integer = 1054
Private Const WM_CAP_DLG_VIDEOFORMAT As Integer = 1065
Private Const WM_CAP_DLG_VIDEOSOURCE As Integer = 1066
Private Const WM_CLOSE As Integer = &H10
Private mCapHwnd As Integer
[ô]tirar foto
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
[ô]Tirar Foto[ô]
My.Computer.Clipboard.Clear()
SendMessage(mCapHwnd, WM_CAP_GRAB_FRAME, 0)
SendMessage(mCapHwnd, WM_CAP_EDIT_COPY, 0)
Picture1.Image = My.Computer.Clipboard.GetImage()
Timer1.Enabled = False
Timer1.Interval = 50
Dim destino As String
Dim novonome As String
destino = [Ô]C:\Diet\diet\Fotos\[Ô]
novonome = IdTextBox.Text + [Ô].[Ô] + TextBox2.Text + [Ô].jpeg[Ô]
TXTDESTINO.Text = destino & novonome
Button4.Enabled = True
Button3.Enabled = True
[ô]nova foto
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
[ô]Nova Foto[ô]
TXTDESTINO.Text = [Ô][Ô]
SendMessage(mCapHwnd, WM_CAP_DRIVER_DISCONNECT, 0)
mCapHwnd = capCreateCaptureWindow([Ô]captura Janela[Ô], 0, 0, 0, 320, 240, Me.Handle.ToInt32, 0)
SendMessage(mCapHwnd, WM_CAP_DRIVER_CONNECT, 0)
Timer1.Enabled = True
Timer1.Interval = 50
[ô]salvar foto
Public Sub salvar_foto()
Dim dados As IDataObject
Dim bmap As Image
[ô] Copia a imagem para o clipboard
SendMessage(mCapHwnd, WM_CAP_EDIT_COPY, 0)
[ô] Obtem a imagem do clipboard e converte para bitmap
dados = Clipboard.GetDataObject()
If dados.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
bmap = CType(dados.GetData(GetType(System.Drawing.Bitmap)), Image)
Picture1.Image = bmap
bmap.Save(TXTDESTINO.Text)
[ô] If sfdimage.ShowDialog = System.Windows.Forms.DialogResult.OK Then
[ô]bmap.Save(sfdimage.FileName, Imaging.ImageFormat.Jpeg)
[ô] End If
End If
Timer1.Enabled = False
Timer1.Interval = 50
[ô] MessageBox.Show([Ô]FOTO SALVA COM SUCESSO[Ô])
Button5.Enabled = True
Button2.Enabled = False
Button3.Enabled = True
Button4.Enabled = False
[ô]ligar webcam
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
SendMessage(mCapHwnd, WM_CAP_GRAB_FRAME, 0)
SendMessage(mCapHwnd, WM_CAP_EDIT_COPY, 0)
Picture1.Image = My.Computer.Clipboard.GetImage()
End Sub
Button2.Enabled = True
End Sub
[ô]desligar webcam
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
[ô]Desliga a câmera
SendMessage(mCapHwnd, WM_CAP_DRIVER_DISCONNECT, 0)
[ô] MsgBox([Ô]!!!SE VOCE JA TIROU A FOTO VOLTE PARA TELA DE CADASTRO E CARREGUE A FOTO!!![Ô])
[ô]Picture1.Image.Dispose()
Button1.Enabled = True
Picture1.Image = Picture1.InitialImage
TXTDESTINO.Text = [Ô][Ô]
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
[ô]Exibe imagem continua no pictubox
My.Computer.Clipboard.Clear()
SendMessage(mCapHwnd, WM_CAP_GRAB_FRAME, 0)
SendMessage(mCapHwnd, WM_CAP_EDIT_COPY, 0)
Picture1.Image = My.Computer.Clipboard.GetImage()
System.Windows.Forms.Application.DoEvents()
End Sub
Tópico encerrado , respostas não são mais permitidas