In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user
-
I am getting error in the following code... ---------------------------------------------------------------------------------------
/* odbAdapter is an object of OleDBAdapter objConnection is an object of OleDBConnection ds is a datatset */ odbAdapter = New OleDbDataAdapter("select * from tblEmployeeAttendance", objConnection) ap.Fill(ds, "EmpAttendance") Dim i As Integer = ds.Tables(0).Rows.Count
--------------------------------------------------------------------------------------- When I add a watch on "ds.Tables(0).Rows" add check its Items property.... I see "In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user." Following is the structure of tblEmployeeAttendance table in an MS Acceess database. ID - AutoNumber EmployeeCode - Text AttendanceDate - date/Time AttendanceCode - Text AttendanceDescription - Text AttendanceDescriptionDate - Date/Time ------------------------------------------------- Do you have any idea about the cause of this error...? Thanks, Arun“The woods are lovely, dark and deep. But I have promises to keep, and miles to go before I sleep.”
-
I am getting error in the following code... ---------------------------------------------------------------------------------------
/* odbAdapter is an object of OleDBAdapter objConnection is an object of OleDBConnection ds is a datatset */ odbAdapter = New OleDbDataAdapter("select * from tblEmployeeAttendance", objConnection) ap.Fill(ds, "EmpAttendance") Dim i As Integer = ds.Tables(0).Rows.Count
--------------------------------------------------------------------------------------- When I add a watch on "ds.Tables(0).Rows" add check its Items property.... I see "In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user." Following is the structure of tblEmployeeAttendance table in an MS Acceess database. ID - AutoNumber EmployeeCode - Text AttendanceDate - date/Time AttendanceCode - Text AttendanceDescription - Text AttendanceDescriptionDate - Date/Time ------------------------------------------------- Do you have any idea about the cause of this error...? Thanks, Arun“The woods are lovely, dark and deep. But I have promises to keep, and miles to go before I sleep.”
You have to supply the row index to view the data with in. In this case you would have to watch
ds.Tables(0).Rows(0).ItemArray
in order to see the first row in the table. But if you have Visual Studio 2005 you can do a QuickWatch and click on the magnify glass icon to actually load the whole database into a grid to view the data...not available in VS2003 though. Hope this helps. -
You have to supply the row index to view the data with in. In this case you would have to watch
ds.Tables(0).Rows(0).ItemArray
in order to see the first row in the table. But if you have Visual Studio 2005 you can do a QuickWatch and click on the magnify glass icon to actually load the whole database into a grid to view the data...not available in VS2003 though. Hope this helps.Thanks for your help. Now, using Dim i As String = dsToupdate.Tables(0).Rows(0).Item(0) returns correct value. But how can I use it in looping through each row in the data set... Currently my code looks like this...
For Each dr As DataRow In dsToupdate.Tables(0).Rows If (dsToupdate.Tables(0).Rows.Count > 0 And (Not (dr.Item("EAR_Employee_Code") Is Nothing))) Then dr.Item("EAR_Employee_Code") = strEmpCode dr.Item("EAR_Attendance_Date") = dtpAttendanceDate.Value dr.Item("EAR_Attendance_Code") = strIsPresent dr.Item("EAR_Attendance_Desc") = strDesc dr.Item("EAR_Attendance_DescDate") = strDescdate End If Next
------------------ can you please provide me a hint how to change the above code to access each item in each data row...? I am using VS2005. Thanks, Arun“The woods are lovely, dark and deep. But I have promises to keep, and miles to go before I sleep.”
-
Thanks for your help. Now, using Dim i As String = dsToupdate.Tables(0).Rows(0).Item(0) returns correct value. But how can I use it in looping through each row in the data set... Currently my code looks like this...
For Each dr As DataRow In dsToupdate.Tables(0).Rows If (dsToupdate.Tables(0).Rows.Count > 0 And (Not (dr.Item("EAR_Employee_Code") Is Nothing))) Then dr.Item("EAR_Employee_Code") = strEmpCode dr.Item("EAR_Attendance_Date") = dtpAttendanceDate.Value dr.Item("EAR_Attendance_Code") = strIsPresent dr.Item("EAR_Attendance_Desc") = strDesc dr.Item("EAR_Attendance_DescDate") = strDescdate End If Next
------------------ can you please provide me a hint how to change the above code to access each item in each data row...? I am using VS2005. Thanks, Arun“The woods are lovely, dark and deep. But I have promises to keep, and miles to go before I sleep.”
I guess I really don't understand what you are asking. I think you are doing it correctly. You do not need the
dsToupdate.Tables(0).Rows.Count > 0
check because the For Each statement will not run if the table is empty. But I don't know of any other way to access each column in the data row. It's easier to user the column names like you did here, than to use the indexes of the columns. Unless you are setting all of the items to the same number, in which case you can loop through the columns inside your row loop...by adding something like this:For Each dc as DataColumn in dsToupdate.Tables(0).Columns dr.Item(dc.Name) = "VALUE" Next
Hope this helps. -
I guess I really don't understand what you are asking. I think you are doing it correctly. You do not need the
dsToupdate.Tables(0).Rows.Count > 0
check because the For Each statement will not run if the table is empty. But I don't know of any other way to access each column in the data row. It's easier to user the column names like you did here, than to use the indexes of the columns. Unless you are setting all of the items to the same number, in which case you can loop through the columns inside your row loop...by adding something like this:For Each dc as DataColumn in dsToupdate.Tables(0).Columns dr.Item(dc.Name) = "VALUE" Next
Hope this helps.Hi! With the help of your first post I successfully solved the issue. A 5 from my side. Thanks a bunch... :) Bye
“The woods are lovely, dark and deep. But I have promises to keep, and miles to go before I sleep.”