samedi 9 mai 2015

sqlreader stopped when the value in database is NULL

Im new to vb and im creating a project where I can edit a account so far Im 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.

Aucun commentaire:

Enregistrer un commentaire