Hi,
I have the following code - I am on cellcontent click I would like to populate textbox values and an image. See code below
I get the error message:
Please help!
Thanks
I have the following code - I am on cellcontent click I would like to populate textbox values and an image. See code below
Code:
Dim conn As SqlConnection = GetDbConnection()
Dim command As New SqlCommand("SELECT * FROM dbo.tbltenants WHERE nationalID=@nationalid", conn)
command.Parameters.Add("@nationalid", SqlDbType.VarChar).Value = DgTenantDetails.Rows(e.RowIndex).Cells(6).Value
Dim table As New DataTable()
Dim adapter As New SqlDataAdapter(command)
adapter.Fill(table)
TxtFNameUp.Text = table.Rows(0)(1).ToString()
TxtLNameUp.Text = table.Rows(0)(2).ToString()
TxtTelUp.Text = table.Rows(0)(4).ToString()
TxtEmailUp.Text = table.Rows(0)(5).ToString()
TxtNationalIDUp.Text = table.Rows(0)(6).ToString()
If table.Rows.Count() <= 0 Then
MessageBox.Show("No image available for this National ID")
Else
Dim img() As Byte
img = table.Rows(0)(7)
Dim ms As New MemoryStream(img)
PictureBox1.Image = Image.FromStream(ms)
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End If
I get the 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'
Thanks