i created a profile of saving a employee details i also want to store their photos in database . i am working in vb.net 2005 and microsoft access as backend.I done all other task except image loading .The image is not loaded or saved
from picturebox to database .I think it must first converted to binary before doint that.but i dont knw the cdoding of that .In Access we can declare a field with datatype oleobject .MY QUESTION IS THAT HOW CAN I LOAD IMAGE TO
THAT FIELD FROM PICTUREBOX IMAGE OBJECT..!!!!!!!!!!
I BELEIVE YOU WILL HELP ME!!!!!!!!!!!!!!!!!!
CODE
Public Class employee_profile
Dim w As System.Byte
Dim u As Object
Dim s As BindingManagerBase
Dim dt As New DataTable
Dim dr As DataRow
Dim k As Integer
Dim d As New OpenFileDialog
Dim da As New DialogResult
Dim y As Bitmap
Dim x1 As Graphics
Public Username As String
Dim e1 As Image
Dim k1 As Object
Dim f As Integer
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs)
End Sub
Private Sub employee_profile_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
s = Me.BindingContext(Employee_prf1, "empd")
OleDbDataAdapter1.Fill(Employee_prf1)
k = s.Position
dt = Employee_prf1.Tables("empd")
End Sub
Private Sub DONE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x, i As Integer
Dim g As Date
g = Date.Now
x = Len(t8.Text)
If t2.Text = "" Or t4.Text = "" Or t5.Text = "" Or t6.Text = "" Or t7.Text = "" Or (r1.Checked = False And r2.Checked = False And r3.Checked = False And r4.Checked = False) Then
MsgBox("enter appropriate column fields")
Exit Sub
End If
If (Val(t8.Text) = 0 Or x <> 10) And c1.Checked = False Then
MsgBox("check ur phone no")
Exit Sub
End If
If t5.Text <> pass.Text Then
MsgBox("password mismatch", MsgBoxStyle.ApplicationModal)
Exit Sub
End If
OleDbDataAdapter1.Fill(Employee_prf1)
s = Me.BindingContext(Employee_prf1, "empd")
Username = t4.Text
k = 0
i = s.Count - 1
For i = 0 To s.Count - 1
dt = Employee_prf1.empd
dr = dt.Rows(k)
If Username = dr(2) Then
MessageBox.Show("Username is not available.please try another name", "User Validation", MessageBoxButtons.OK, MessageBoxIcon.Information)
t4.Focus()
Exit Sub
End If
k = k + 1
Next
k = 0
OleDbDataAdapter2.Fill(Regd1)
s = Me.BindingContext(Regd1, "regemp")
For i = 0 To s.Count - 1
dt = Regd1.regemp
dr = dt.Rows(k)
If Username = dr(3) Then
MessageBox.Show("Username is not available.please try another name", "User Validation", MessageBoxButtons.OK, MessageBoxIcon.Information)
t4.Focus()
Exit Sub
End If
k = k + 1
Next
OleDbDataAdapter1.Fill(Employee_prf1)
s = Me.BindingContext(Employee_prf1, "empd")
Try
dt = Employee_prf1.Tables("empd")
dr = dt.NewRow
dr(0) = t2.Text
dr(1) = t3.Text
dr(2) = t4.Text
dr(3) = t5.Text
dr(4) = t6.Text
dr(5) = t7.Text
If c1.Checked = True Then
dr(6) = 0
Else
dr(6) = (t8.Text)
End If
dr(7) = t9.Text
If r1.Checked = True Then
dr(8) = "Manager"
ElseIf r2.Checked = True Then
dr(8) = "Pharmist"
ElseIf r3.Checked = True Then
dr(8) = "Salesman"
Else
dr(8) = "other"
End If
dr(9) = g
MsgBox(g)
dt.Rows.Add(dr)
OleDbDataAdapter1.Update(Employee_prf1, "empd")
MessageBox.Show("record created successfully! your accout will be activated after moderator approval", "record information", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
t2.Text = ""
t3.Text = ""
t4.Text = ""
t5.Text = ""
t6.Text = ""
t7.Text = ""
t8.Text = ""
t9.Text = ""
pass.Text = ""
c1.Checked = False
Catch ex As Exception
MsgBox(ex.Message & "error in input")
End Try
End Sub
Private Sub t7_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles t7.TextChanged
End Sub
Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
Dim i, f As Integer
If t4.Text = "" Then
MsgBox("USERNAME FIELD IS BLANK CHECK WHETHER YOU TYPE IT")
Exit Sub
End If
Username = t4.Text
k = 0
i = s.Count - 1
OleDbDataAdapter1.Fill(Employee_prf1)
s = Me.BindingContext(Employee_prf1, "empd")
For i = 0 To s.Count - 1
dt = Employee_prf1.empd
dr = dt.Rows(k)
If Username = dr(2) Then
MessageBox.Show("Username is not available.please try another name", "User Validation", MessageBoxButtons.OK, MessageBoxIcon.Information)
f = 1
t4.Focus()
Exit For
End If
k = k + 1
Next
k = 0
OleDbDataAdapter2.Fill(Regd1)
s = Me.BindingContext(Regd1, "regemp")
For i = 0 To s.Count - 1
dt = Regd1.regemp
dr = dt.Rows(k)
If Username = dr(3) Then
MessageBox.Show("Username is not available.please try another name", "User Validation", MessageBoxButtons.OK, MessageBoxIcon.Information)
f = 1
t4.Focus()
Exit For
End If
k = k + 1
Next
If f <> 1 Then
MessageBox.Show("Username is available !continue", "User Validation", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub c1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles c1.CheckedChanged
t8.Text = ""
End Sub
Private Sub LinkLabel1_LinkClicked_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
Me.d.Filter = "Images (*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*"
d.ShowDialog()
d.RestoreDirectory = True
'da = d.ShowDialog
p1.ImageLocation = d.FileName
y = p1.Image
t13.Text = d.FileName
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles p1.Click
End Sub
Private Sub t13_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles t13.TextChanged
End Sub
End Class