Hi,
I am trying to retrieve image and display it on the picturebox2 on datagridview cellmouseclick but receive the following error message:
The code I am using is:
Secondly, issue (2) when I click on the datagridview I also receive the following error message:
Note: firstname is not NULL - I dont understand.
Thanks
I am trying to retrieve image and display it on the picturebox2 on datagridview cellmouseclick but receive the following error message:
Code:
System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index'
Code:
This exception was originally thrown at this call stack:
[External Code]
RCMS.FrmRegisterTenant.DgTenantDetails_CellMouseClick(Object, System.Windows.Forms.DataGridViewCellMouseEventArgs) in FrmRegisterTenant.vb
[External Code]
Code:
Private Sub DgTenantDetails_CellMouseClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DgTenantDetails.CellMouseClick
Dim conn As SqlConnection = GetDbConnection()
Call TenantsDetailsDisable()
If e.RowIndex >= 0 Then
Dim row As DataGridViewRow = DgTenantDetails.Rows(e.RowIndex)
TxtFNameUp.Text = row.Cells(1).Value.ToString
TxtLNameUp.Text = row.Cells(2).Value.ToString
TxtTelUp.Text = row.Cells(3).Value.ToString
TxtEmailUp.Text = row.Cells(4).Value.ToString
TxtNationalIDUp.Text = row.Cells(5).Value.ToString
Dim img As Byte
img = DgTenantDetails.Item(7, e.RowIndex).Value
Dim ms As New MemoryStream(img)
PictureBox2.Image = Image.FromStream(ms)
PictureBox2.SizeMode = PictureBoxSizeMode.StretchImage
End If
End Sub
Code:
The following exception occurred in the DataGridView.
System.Data.NoNullAllowedException: Column 'firstname' does not allow null
Thanks