worldatlas
MIS
I have the following error msg, and I don't know what I have to do to solve it.
Server Error in '/ExamConn' Application.
--------------------------------------------------------------------------------
These columns don't currently have unique values.
Exception Details: System.ArgumentException: These columns don't currently have unique values.
Source Error:
Line 70: ds.Relations.Add(dr)
________________________
I have two tables tblActivities & tblEmployee
One employee can have many activities:
Anyhow, I'm trying to populate a datagrid with activites and their correspondent employee's last name & first name.
So my code are as follow:
Dim dr As DataRelation
Dim parentCol As DataColumn
Dim childCol As DataColumn
parentCol = ds.Tables("V_ActivityHistoryDetail").Columns("Refference")
childCol = ds.Tables("V_EmployeeName").Columns("EmployeePayrollNumber")
dr = New DataRelation("ActEmployee", parentCol, childCol)
ds.Relations.Add(dr)
Dim strResultsHolder As String = "<table width=100% border=1>"
Dim r As DataRow
Dim c As DataColumn
'create the table header
strResultsHolder &= "<tr><td>Account<br> Unit</td><td> Activity</td><td> Account<br/>Category</td><td>Account<br/> Number </td><td>Amount</td><td>Description</td><td>Reference </td><td>Units</td>"
For Each c In ds.Tables("V_ActivityHistoryDetail").Columns
strResultsHolder &= "<td>" & c.ColumnName.ToString() & " </td>"
Next
For Each r In ds.Tables("V_ActivityHistoryDetail").Rows
'create childr as an array of Datarow object
Dim childr() As DataRow
'now we get the child rows from the relationship
childr = r.GetChildRows("ActEmployee")
'now we loop through all the child row
Dim theChildRow As DataRow
For Each theChildRow In childr
'now we can looop through all the columns in that child row
strResultsHolder &= "</tr><tr>"
strResultsHolder &= "td>" & theChildRow("LastName") & "</td><td>" & _
theChildRow("FirstName") & "</td>"
For Each c In ds.Tables("V_ActivityHistoryDetail").Columns
strResultsHolder &= "<td>" & r(c.ColumnName).ToString() & "</td>"
Next
Next
Next
distable.InnerHtml = strResultsHolder
__________________________________
I even try to switch the parent & child column around, but not every employee is on the activities table..So how can I code where it only applies to the one that they match. Any help is greatly appreciated.
Server Error in '/ExamConn' Application.
--------------------------------------------------------------------------------
These columns don't currently have unique values.
Exception Details: System.ArgumentException: These columns don't currently have unique values.
Source Error:
Line 70: ds.Relations.Add(dr)
________________________
I have two tables tblActivities & tblEmployee
One employee can have many activities:
Anyhow, I'm trying to populate a datagrid with activites and their correspondent employee's last name & first name.
So my code are as follow:
Dim dr As DataRelation
Dim parentCol As DataColumn
Dim childCol As DataColumn
parentCol = ds.Tables("V_ActivityHistoryDetail").Columns("Refference")
childCol = ds.Tables("V_EmployeeName").Columns("EmployeePayrollNumber")
dr = New DataRelation("ActEmployee", parentCol, childCol)
ds.Relations.Add(dr)
Dim strResultsHolder As String = "<table width=100% border=1>"
Dim r As DataRow
Dim c As DataColumn
'create the table header
strResultsHolder &= "<tr><td>Account<br> Unit</td><td> Activity</td><td> Account<br/>Category</td><td>Account<br/> Number </td><td>Amount</td><td>Description</td><td>Reference </td><td>Units</td>"
For Each c In ds.Tables("V_ActivityHistoryDetail").Columns
strResultsHolder &= "<td>" & c.ColumnName.ToString() & " </td>"
Next
For Each r In ds.Tables("V_ActivityHistoryDetail").Rows
'create childr as an array of Datarow object
Dim childr() As DataRow
'now we get the child rows from the relationship
childr = r.GetChildRows("ActEmployee")
'now we loop through all the child row
Dim theChildRow As DataRow
For Each theChildRow In childr
'now we can looop through all the columns in that child row
strResultsHolder &= "</tr><tr>"
strResultsHolder &= "td>" & theChildRow("LastName") & "</td><td>" & _
theChildRow("FirstName") & "</td>"
For Each c In ds.Tables("V_ActivityHistoryDetail").Columns
strResultsHolder &= "<td>" & r(c.ColumnName).ToString() & "</td>"
Next
Next
Next
distable.InnerHtml = strResultsHolder
__________________________________
I even try to switch the parent & child column around, but not every employee is on the activities table..So how can I code where it only applies to the one that they match. Any help is greatly appreciated.