I have a table in my database which is named Patients. The table has a column which is named DOB and has Allow Null value to true. Here is the table structure:
- Id int IDENTITY(1,1) NOT NULL,
- FirstName nvarchar(50) NULL,
- LastName nvarchar(50) NULL,
- Sex bit NULL,
- Weight decimal(18, 0) NULL,
- Height decimal(18, 0) NULL,
- DOB date NULL,
- PatientId nvarchar(50) NOT NULL
I'm using LinqToSql. The problem is that when I want to set a null for DOB column then Visual Studio tells that DOB is not nullable. Here is my code:
Patient tblPatient = new Patient();
if (txtYear.Text != "" && txtMonth.Text != "" && txtDay.Text != "")
tblPatient.DOB = Utility.ConvertPersianDateToGregorianDate(txtYear.Text + "/" + txtMonth.Text + "/" + txtDay.Text);
else
tblPatient.DOB = null; // The error is in this line
Patientwhat is the type ofDOBproperty? - Felipe OrianiDateTime. - Mohsen