Hi
I'm creating a database app based on many of the concepts in the Beginning VB05 Databases book (Similar to TimeTracker - totally different purpose). The MS Access 2003 db that sits under has a list of projects and dates including: Early Start, Baseline Start, Actual Start, Baseline Finish Actual Finish. Of course as some projects may not have actually finished there will be blanks in some fields.
My problems are two:
First Problem:
Using objData to populate the list view of Projects as follows. Any blank dates cause the ListView control to stop populating - it doesn't throw an exception - just stops populating. Am I doing something terribly wrong?
Code:
Get all projects in a DataReader object
objData.SQL = "usp_ProjectDetails"
objData.InitializeCommand()
objData.OpenConnection()
objData.DataReader = objData.Command.ExecuteReader
'See if any data exists before continuing
If objData.DataReader.HasRows Then
lvwADProjects.Items.Clear()
'Process all rows
While objData.DataReader.Read()
'create a new ListViewItem
objListViewItem = New ListViewItem
'add data to the listviewitem
objListViewItem.Tag = objData.DataReader.Item("Project_ID")
'add the subitems to the listviewitem
objListViewItem.Text = objData.DataReader.Item("Project_Title")
objListViewItem.SubItems.Add(objData.DataReader.Item("Phase_Title"))
objListViewItem.SubItems.Add(objData.DataReader.Item("Project_Status"))
objListViewItem.SubItems.Add(objData.DataReader.Item("Early_Finish"))
objListViewItem.SubItems.Add(objData.DataReader.Item("SH_Surname"))
'add the listviewitem to the listview control
lvwADProjects.Items.Add(objListViewItem)
End While
End If
objData.DataReader.Close()
Catch ExceptionErr As Exception
MessageBox.Show(ExceptionErr.Message, strAppTitle)
Second Problem:
I'm trying to insert projects with dates into the Database. But I consistently get a failed to convert String to DateTime error. This one is driving me batty.
Here's a line of the insertion code:
objData.AddParameter("@Early_Start", OleDb.OleDbType.DBDate, 20, CType(txtADProjectCurrentStart.Text, Date))
The parameter is @Early_Start in the SQL line and the format in Access in DateTime. The SQL usp works fine in Access with the same format data as appears in the text box.
ANY help appreciated as this is stumping me on an otherwise great app!
Cheers
Ray