Christineeve
Programmer
Dear Experts:
I've looked high and low all over the web. I'm stuck with handling this null date being retrieved with DAL from my MS Access Database. I have researched this for a long time. Specific help would mean a lot to me.
Here the database date field is empty. The code crashes. I'd like to handle the error and pass in a default date of
#1/1/1985#
I don't know how to handle the error or what way is best for handling the retrieval of this error.
Thank you so much!
Christine
I've looked high and low all over the web. I'm stuck with handling this null date being retrieved with DAL from my MS Access Database. I have researched this for a long time. Specific help would mean a lot to me.
Code:
Dim cmdRevEmp As New OleDbCommand
Dim daRevEmp As New OleDbDataAdapter
Dim dsRevEmp As New DataSet
Dim dtRevEmp As New DataTable
Dim DataSource As String = gMyDataSource
Dim m_cnADONetConnection As New OleDb.OleDbConnection
m_cnADONetConnection.ConnectionString = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & DataSource & ";User ID=Admin;Password=;")
m_cnADONetConnection.Open()
cmdRevEmp = m_cnADONetConnection.CreateCommand
cmdRevEmp.CommandText = "SELECT * FROM tblEmpInfo Where pk_EmpInfoID=" & empID
'Create the command object and the dataset to hold all the employee data from tblEmpInfo
daRevEmp.SelectCommand = cmdRevEmp
daRevEmp.Fill(dsRevEmp, "RevEmps")
dtRevEmp = dsRevEmp.Tables("RevEmps")
dsRevEmp = New DataSet
daRevEmp.Fill(dsRevEmp, "RevEmps")
If (dtRevEmp.Rows.Count > 0) Then
'Retrieve the data from the Access database and populate some textboxes, comboboxes, and masked text boxes.
txtPrNationlty.Text = dtRevEmp.Rows(m_rowPosition)("empCountry").ToString()
Here the database date field is empty. The code crashes. I'd like to handle the error and pass in a default date of
#1/1/1985#
Code:
mtxtPrBirth.Text = dtRevEmp.Rows(m_rowPosition)("empbirthDate")
I don't know how to handle the error or what way is best for handling the retrieval of this error.
Thank you so much!
Christine