I have a visual Basic .net 1.1 windows application connected to an access database.
One one of the pages there is a drop down box, and depending on the selection of a project ID (the combo box is populated from a table in the access database) I want a datagrid to populated with all of the rows in a table called Task that have this Project ID.
This is the code I am using but it keeps erroring when I click on the combo box.
Code:
It errors on the line "OleDbDataAdapterTasks.Fill(ProjectsDataSet1)" with this error - "An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in microsoft.visualbasic.dll"
Does anyone know why?
One one of the pages there is a drop down box, and depending on the selection of a project ID (the combo box is populated from a table in the access database) I want a datagrid to populated with all of the rows in a table called Task that have this Project ID.
This is the code I am using but it keeps erroring when I click on the combo box.
Code:
VB.NET:
Private Sub cbxProjectID_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbxProjectID.SelectedIndexChanged
Dim ProjectID As Integer
ProjectID = cbxProjectID.SelectedValue
Dim OleDbDataAdapterTasks = New OleDb.OleDbDataAdapter
Dim ProjectsDataSet1 = New DataSet
Dim cmdTasks As OleDb.OleDbCommand
cmdTasks = New OleDb.OleDbCommand("Select * From Tasks WHERE [Proj_ID] = " & ProjectID, OleDbConnection1)
cmdTasks.CommandType = CommandType.TableDirect
OleDbDataAdapterTasks.SelectCommand = cmdTasks
OleDbConnection1.Open()
OleDbDataAdapterTasks.Fill(ProjectsDataSet1)
OleDbConnection1.Close()
grdTasks.DataSource = ProjectsDataSet1.Task
grdTasks.DataMember = "Task"
grdTasks.CaptionText = "Tasks"
End Sub
It errors on the line "OleDbDataAdapterTasks.Fill(ProjectsDataSet1)" with this error - "An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in microsoft.visualbasic.dll"
Does anyone know why?