How send picture column from datagridview form1 to picturebox form2

  • Thread starter Thread starter jepoyman
  • Start date Start date
J

jepoyman

Guest
Please help

I would like to pass data from datagridview form1 to form2, what will happen is that when the datagridview selected row will be double clicked form 2 will be opened and will send textbox1 will be firstname, textbox2 will be lastname, textbox3 will be timestamp, textbox4 will be captured datatime and then picture will be sent to picture box. I was able to successfully password the data from textboxes but not on the picturebox

This will be my codes on form1


Private Sub DataGridView1_DoubleClick(sender As Object, e As EventArgs) Handles DataGridView1.DoubleClick
If DataGridView1.SelectedRows.Count > 0 Then
For Each frm As Form In Application.OpenForms
If TypeOf frm Is frmUpdateAttendance Then
frm.Activate()
Return
End If
Next

Dim fm As New frmUpdateAttendance
fm.txtFirstname.Tag = DataGridView1.Item(0, DataGridView1.CurrentRow.Index).Value
fm.MdiParent = frmMDI
fm.Show()
fm = Nothing
End If
End Sub


Private Sub Load_Data()
txtSearch.Text.Trim()

Command = New OleDbCommand
Adapter = New OleDbDataAdapter
DTable = New DataTable

Connection = New OleDbConnection(StrCon)
With Connection
If .State = ConnectionState.Closed Then
.ConnectionString = StrCon
.Open()
End If
End With

Command.Connection = Connection
Command.CommandType = CommandType.Text
sql = " SELECT AttID, fname, lname, srno, datetime, capturedpic FROM Attendance WHERE fname + ', ' + lname LIKE '%%" & txtSearch.Text &
"%%' OR fname + ' ' + lname = '" & txtSearch.Text & "'"
Command.CommandText = sql
Adapter.SelectCommand = Command
Adapter.Fill(DTable)
DataGridView1.DataSource = DTable

If DTable.Rows.Count = 0 Then
MsgBox("Information being searched was not found in database ..." + vbNewLine + vbNewLine & txtSearch.Text, MsgBoxStyle.Information, "Try again")
End If
Connection.Close()
End Sub


Form2

Codes for the form2 to receive the textboxes and picture


Private Sub Load_Data()

Command = New OleDbCommand
Connection = New OleDbConnection(StrCon)

With Connection
If .State = ConnectionState.Closed Then
.ConnectionString = StrCon
.Open()
End If
End With

With Command
.Connection = Connection
.CommandType = CommandType.Text
.CommandText = " SELECT AttID, fname, lname, srno, datetime, capturedpic " &
" FROM Attendance WHERE AttID = " & txtFirstname.Tag
End With

Reader = Command.ExecuteReader
If Reader.HasRows Then
While Reader.Read
txtFirstname.Text = Reader("AttID")
txtFirstname.Text = IIf(Not IsDBNull(Reader("fname")), Reader("fname"), "")
txtLastname.Text = IIf(Not IsDBNull(Reader("lname")), Reader("lname"), "")
txtTimeStamp.Text = IIf(Not IsDBNull(Reader("srno")), Reader("srno"), "")
txtDateTime.Text = IIf(Not IsDBNull(Reader("datetime")), Reader("datetime"), "")
End While
End If
Reader.Close()
Connection.Close()
End Sub

Continue reading...
 
Back
Top