samedi 9 mai 2015

SqlDataReader stopped when the value in database is NULL

I'm new to vb and I'm creating a project where I can edit a account so far I'm having trouble with it. The .read function stopped when the value in my database is NULL

ElseIf ButtonChoice = 2 Then
            txtIDnumber.Text = val
            Dim EditFamilyProfile As New SqlCommand("Select * From [186].[dbo].[familyInfo] WHERE pFnumber = @pFnumber", Connection)
            EditFamilyProfile.CommandType = CommandType.Text
            EditFamilyProfile.Parameters.AddWithValue("@pFnumber", txtIDnumber.Text)
            Dim drEdit As SqlDataReader
            drEdit = EditFamilyProfile.ExecuteReader
            With drEdit
                .Read()
                txtLastName.Text = .Item(1)
                txtFirstName.Text = .Item(2)
                txtMiddleName.Text = .Item(3)
                txtExt.Text = .Item(4)
                txtAddress.Text = .Item(5)
                cmbGender.Text = .Item(6)
.close()
            End With
        End If

It stopped in txteExt.text because it has a NULL value. There is no error shown. Its just go to the code:

  ButtonChoice = 2
        Dim obb As New frm_FamilyReg
        obb.val = Me.txtIDnumber.Text()
        obb.Show()
        Me.Close()

Aucun commentaire:

Enregistrer un commentaire