Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple ques abt property and data type

Status
Not open for further replies.

purplehaze1

Programmer
Jul 23, 2003
86
US
In SQL Server database, Social Security field is defined as integer which is not
a required field and may have null value. So, in my program, I have public property
SocialSecurity that returns integer. My problem is, if the user doesn't enter
ss number, then I get an error. How can I solve this problem? Thanks.
e.g.




Public Property SocialSecurity() As integer
Get
Return m_ssnum
End Get
Set(ByVal Value As integer)
m_ssnum = Value
IsDirty = True
End Set
End Property


'the code fails if social security is left blank

With oPatient
.CustomerID = cbTC.SelectedValue
.genderID = cbGender.SelectedValue
.RecipCareStatusID = IIf(cbPStatus.Text = "Inpatient", 1, 2)
.RaceID = cbRace.SelectedValue
.FirstName = txtFName.Text.ToString().Trim()
.MiddleInitial = txtMInit.Text.ToString().Trim()
.LastName = txtLName.Text.ToString().Trim()
.DOB = CType(dtbday.Text, Date)
.USResident = IIf(rResidentYes.Checked, "Y", "N")
.SocialSecurity = txtSSNum.Text.Trim()
End With
 
test for database nulls with
Code:
if *SSN Here* Is System.DBNull.Value then
   'no ssn
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top