AJUDA COM IMAGEM EM BD ACESS......
essa briga toda so pra conseguir fazer esse sistema de login
video demonstração ainda falta arrumar alguns coisas mais ainda num ta do jeito que eu quero vo conseguir de alguma forma que ele leia tipo nessa sequencia
usuario,senha, se for correto ele ler o campo foto e exibir em conjunto mais to chegando la.
video http://www.youtube.com/watch?v=WoxXObZRRbo
video demonstração ainda falta arrumar alguns coisas mais ainda num ta do jeito que eu quero vo conseguir de alguma forma que ele leia tipo nessa sequencia
usuario,senha, se for correto ele ler o campo foto e exibir em conjunto mais to chegando la.
video http://www.youtube.com/watch?v=WoxXObZRRbo
KURTGU, só não esqueça de fechar o tópico!
nao sei o que aconteceu meu notebook de um pau ontem e perdi o projeto e nao tinha feito backup agora toda vez que mando salva o caminho da foto no bd ta dando erro por favor alguem poderia da uma olhada nesse codigo e ve o que ta errado na parte de salvar no bd o caminho da foto....e depois eu coloco esses dados em um listview agora so ta indo o nome e a senha o campo foto nao ta salvando nem enviando para o listview....
Imports System.Data
Imports System.Data.OleDb
Public Class Form3
Inherits System.Windows.Forms.Form
Dim mypath = Application.StartupPath & [Ô]\Login.mdb[Ô]
Dim mypassword = [Ô][Ô]
Dim conn As New OleDbConnection([Ô]Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Login.mdb[Ô] & [Ô];Jet OLEDB:Database Password=[Ô] & mypassword)
Dim cmd As OleDbCommand
_______________________________________________________________________________________________________________________________________________
Private Sub BtnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdd.Click
LblAdd_Edit.Text = [Ô]Add[Ô]
BtnAdd.Enabled = False
BtnSave.Enabled = True
BtnCancel.Enabled = True
BtnEdit.Enabled = False
BtnDelete.Enabled = False
BtnExit.Enabled = False
GroupBox1.Enabled = True
Txtname.Text = [Ô][Ô]
TxtSex.Text = [Ô][Ô]
Txtname.Focus()
End Sub
_______________________________________________________________________________________________________________________________________________
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
DisplayList()
End Sub
_______________________________________________________________________________________________________________________________________________
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
connection()
End Sub
Sub DisplayList()
Dim lst
ListView1.Items.Clear()
rs = New ADODB.Recordset
With rs
.Open([Ô]select * from Login[Ô], cn, 1, 2)
Do While Not .EOF
lst = New ListViewItem
lst = ListView1.Items.Add(.Fields([Ô]Nome[Ô]).Value)
lst.SubItems.Add(.Fields([Ô]Senha[Ô]).Value)
.MoveNext()
Loop
End With
End Sub
_______________________________________________________________________________________________________________________________________________
Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSave.Click
If Txtname.Text = [Ô][Ô] Then : MsgBox([Ô]Erro Nome Em Branco![Ô], MsgBoxStyle.Exclamation) : Txtname.Focus() : Exit Sub : End If
If TxtSex.Text = [Ô][Ô] Then : MsgBox([Ô]Erro Senha Em Branco ![Ô], MsgBoxStyle.Exclamation) : TxtSex.Focus() : Exit Sub : End If
If MsgBox([Ô]Voce Deseja mesmo salvar esse usuário?[Ô], MsgBoxStyle.YesNo, [Ô]Message[Ô]) = MsgBoxResult.No Then : Exit Sub : End If
rs = New ADODB.Recordset
With rs
If LblAdd_Edit.Text = [Ô]Add[Ô] Then
.Open([Ô]Select * from Login[Ô], cn, 1, 2)
.AddNew()
Else
.Open([Ô]Select * from Login where Nome=[ô][Ô] & Me.Text & [Ô][ô][Ô], cn, 1, 2)
End If
.Fields([Ô]Nome[Ô]).Value = Txtname.Text
.Fields([Ô]Senha[Ô]).Value = TxtSex.Text
.Fields([Ô]Foto[Ô]).Value = PictureBox1.Image ---------- O ERRO SEMPRE DA DANDO NESSA LINHA
.Update()
Clear()
End With
DisplayList()
End Sub
________________________________________________________________________________________________________________________________________
Sub Clear()
Txtname.Text = [Ô][Ô]
TxtSex.Text = [Ô][Ô]
BtnAdd.Enabled = True
BtnSave.Enabled = False
BtnCancel.Enabled = False
BtnEdit.Enabled = True
BtnDelete.Enabled = True
BtnExit.Enabled = True
GroupBox1.Enabled = False
End Sub
Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCancel.Click
Clear()
End Sub
___________________________________________________________________________________________________________________________________________
Private Sub BtnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDelete.Click
If MsgBox([Ô]Você Deseja Excluir Esse Usuario ?[Ô], MsgBoxStyle.YesNo, [Ô]Message[Ô]) = MsgBoxResult.No Then : Exit Sub : End If
rs = New ADODB.Recordset
rs.Open([Ô]select * from Login where Nome like [ô][Ô] & Me.Text & [Ô][ô][Ô], cn, 1, 2)
rs.Delete()
DisplayList()
End Sub
________________________________________________________[txt-color=#e80000]CARREGAR OS DADOS NO LISTIVIEW[/txt-color]____________________________________________________
Private Sub ListView1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseClick
rs = New ADODB.Recordset
With rs
.Open([Ô]Select * from Login where Nome like [ô][Ô] & ListView1.FocusedItem.Text & [Ô][ô][Ô], cn, 1, 2)
Txtname.Text = .Fields([Ô]Nome[Ô]).Value
TxtSex.Text = .Fields([Ô]Senha[Ô]).Value
Picturebox1 = .Fields([Ô]Foto[Ô]).Value
End With
End Sub
__________________________________________________________________________________________________________________________________________
Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
Me.Text = ListView1.FocusedItem.Text
End Sub
__________________________________________________________________________________________________________________________________________
Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click
Me.Close()
End Sub
____________________________________________________________[txt-color=#e80000]BOTAO EDITAR O REGISTRO[/txt-color]___________________________________________________
Private Sub BtnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEdit.Click
Me.Text = ListView1.FocusedItem.Text
LblAdd_Edit.Text = [Ô]Edit[Ô]
BtnAdd.Enabled = False
BtnSave.Enabled = True
BtnCancel.Enabled = True
BtnEdit.Enabled = False
BtnDelete.Enabled = False
BtnExit.Enabled = False
GroupBox1.Enabled = True
Txtname.Focus()
TxtSex.Focus()
End Sub
_________________________________________________[txt-color=#e80000]BOTAO PRA CARREGAR FOTO NO PICTUREBOX[/txt-color]__________________________________________
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
PictureBox1.Image = System.Drawing.Image.FromFile(OpenFileDialog1.FileName)
TextBox1.Text = (OpenFileDialog1.FileName)
End If
Catch ex As Exception
End Try
End Sub
______________________________________________________________________________________________________________________________________
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form4.Show()
End Sub
End Class
[txt-color=#e80000]Codigo[/txt-color]_________________________________________________________________________________________________________________________________
Imports System.Data
Imports System.Data.OleDb
Public Class Form3
Inherits System.Windows.Forms.Form
Dim mypath = Application.StartupPath & [Ô]\Login.mdb[Ô]
Dim mypassword = [Ô][Ô]
Dim conn As New OleDbConnection([Ô]Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Login.mdb[Ô] & [Ô];Jet OLEDB:Database Password=[Ô] & mypassword)
Dim cmd As OleDbCommand
_______________________________________________________________________________________________________________________________________________
Private Sub BtnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdd.Click
LblAdd_Edit.Text = [Ô]Add[Ô]
BtnAdd.Enabled = False
BtnSave.Enabled = True
BtnCancel.Enabled = True
BtnEdit.Enabled = False
BtnDelete.Enabled = False
BtnExit.Enabled = False
GroupBox1.Enabled = True
Txtname.Text = [Ô][Ô]
TxtSex.Text = [Ô][Ô]
Txtname.Focus()
End Sub
_______________________________________________________________________________________________________________________________________________
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
DisplayList()
End Sub
_______________________________________________________________________________________________________________________________________________
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
connection()
End Sub
Sub DisplayList()
Dim lst
ListView1.Items.Clear()
rs = New ADODB.Recordset
With rs
.Open([Ô]select * from Login[Ô], cn, 1, 2)
Do While Not .EOF
lst = New ListViewItem
lst = ListView1.Items.Add(.Fields([Ô]Nome[Ô]).Value)
lst.SubItems.Add(.Fields([Ô]Senha[Ô]).Value)
.MoveNext()
Loop
End With
End Sub
_______________________________________________________________________________________________________________________________________________
Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSave.Click
If Txtname.Text = [Ô][Ô] Then : MsgBox([Ô]Erro Nome Em Branco![Ô], MsgBoxStyle.Exclamation) : Txtname.Focus() : Exit Sub : End If
If TxtSex.Text = [Ô][Ô] Then : MsgBox([Ô]Erro Senha Em Branco ![Ô], MsgBoxStyle.Exclamation) : TxtSex.Focus() : Exit Sub : End If
If MsgBox([Ô]Voce Deseja mesmo salvar esse usuário?[Ô], MsgBoxStyle.YesNo, [Ô]Message[Ô]) = MsgBoxResult.No Then : Exit Sub : End If
rs = New ADODB.Recordset
With rs
If LblAdd_Edit.Text = [Ô]Add[Ô] Then
.Open([Ô]Select * from Login[Ô], cn, 1, 2)
.AddNew()
Else
.Open([Ô]Select * from Login where Nome=[ô][Ô] & Me.Text & [Ô][ô][Ô], cn, 1, 2)
End If
.Fields([Ô]Nome[Ô]).Value = Txtname.Text
.Fields([Ô]Senha[Ô]).Value = TxtSex.Text
.Fields([Ô]Foto[Ô]).Value = PictureBox1.Image ---------- O ERRO SEMPRE DA DANDO NESSA LINHA
.Update()
Clear()
End With
DisplayList()
End Sub
________________________________________________________________________________________________________________________________________
Sub Clear()
Txtname.Text = [Ô][Ô]
TxtSex.Text = [Ô][Ô]
BtnAdd.Enabled = True
BtnSave.Enabled = False
BtnCancel.Enabled = False
BtnEdit.Enabled = True
BtnDelete.Enabled = True
BtnExit.Enabled = True
GroupBox1.Enabled = False
End Sub
Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCancel.Click
Clear()
End Sub
___________________________________________________________________________________________________________________________________________
Private Sub BtnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDelete.Click
If MsgBox([Ô]Você Deseja Excluir Esse Usuario ?[Ô], MsgBoxStyle.YesNo, [Ô]Message[Ô]) = MsgBoxResult.No Then : Exit Sub : End If
rs = New ADODB.Recordset
rs.Open([Ô]select * from Login where Nome like [ô][Ô] & Me.Text & [Ô][ô][Ô], cn, 1, 2)
rs.Delete()
DisplayList()
End Sub
________________________________________________________[txt-color=#e80000]CARREGAR OS DADOS NO LISTIVIEW[/txt-color]____________________________________________________
Private Sub ListView1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseClick
rs = New ADODB.Recordset
With rs
.Open([Ô]Select * from Login where Nome like [ô][Ô] & ListView1.FocusedItem.Text & [Ô][ô][Ô], cn, 1, 2)
Txtname.Text = .Fields([Ô]Nome[Ô]).Value
TxtSex.Text = .Fields([Ô]Senha[Ô]).Value
Picturebox1 = .Fields([Ô]Foto[Ô]).Value
End With
End Sub
__________________________________________________________________________________________________________________________________________
Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
Me.Text = ListView1.FocusedItem.Text
End Sub
__________________________________________________________________________________________________________________________________________
Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click
Me.Close()
End Sub
____________________________________________________________[txt-color=#e80000]BOTAO EDITAR O REGISTRO[/txt-color]___________________________________________________
Private Sub BtnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEdit.Click
Me.Text = ListView1.FocusedItem.Text
LblAdd_Edit.Text = [Ô]Edit[Ô]
BtnAdd.Enabled = False
BtnSave.Enabled = True
BtnCancel.Enabled = True
BtnEdit.Enabled = False
BtnDelete.Enabled = False
BtnExit.Enabled = False
GroupBox1.Enabled = True
Txtname.Focus()
TxtSex.Focus()
End Sub
_________________________________________________[txt-color=#e80000]BOTAO PRA CARREGAR FOTO NO PICTUREBOX[/txt-color]__________________________________________
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
PictureBox1.Image = System.Drawing.Image.FromFile(OpenFileDialog1.FileName)
TextBox1.Text = (OpenFileDialog1.FileName)
End If
Catch ex As Exception
End Try
End Sub
______________________________________________________________________________________________________________________________________
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form4.Show()
End Sub
End Class
Tópico encerrado , respostas não são mais permitidas