Dear all,
I have error " There is no row at position 0" at DataColumn Expression.
Can any one help me please??
First Table :-
Second table where I have error is:-
Error appears at above expression.
This table is bound with a DataGrid.
Any help is most appreciated.
Thanks in advance
I have error " There is no row at position 0" at DataColumn Expression.
Can any one help me please??
First Table :-
VB.NET:
Public Function GetCustomerDetail(ByVal CustomerID As String) As DataTable
Dim techConnection As OleDbConnection = New OleDbConnection(strConn)
Dim techDataAdapter As OleDbDataAdapter
Dim dtCustomerDetail As DataTable
Try
Dim strSQL As String = _
"SELECT * FROM Customers WHERE CustomerID = @CustomerID"
Dim techCommand As New OleDbCommand(strSQL, techConnection)
techCommand.Parameters.Add("@CustomerID", OleDbType.VarChar, 20, "CustomerID").Value = CustomerID
techDataAdapter = New OleDbDataAdapter(techCommand)
Dim techCommandBuilder As New OleDbCommandBuilder(techDataAdapter)
dtCustomerDetail = New DataTable
techDataAdapter.Fill(dtCustomerDetail)
Catch EX As OleDbException
MsgBox(EX.Message)
End Try
Return dtCustomerDetail
End Function
Second table where I have error is:-
VB.NET:
Public Function TempCustomer(ByVal DataTableName As String) As DataTable
dt = New DataTable(DataTableName)
dt.Columns.Add(New DataColumn("ItemNo", GetType(Integer)))
dt.Columns.Add(New DataColumn("CustomerID", GetType(String)))
Dim dtCustomerDetail As DataTable = GetCustomerDetail("CustomerID")
Dim dcCustomerName As DataColumn
dcCustomerName = New DataColumn("CustomerName", GetType(String))
dcCustomerName.Expression = dtCustomerDetail.Rows(0)(1) + " " + dtCustomerDetail.Rows(0)(2) ' First Name + Second Name
dt.Columns.Add(dcCustomerName)
Return dt
End Function
Error appears at above expression.
This table is bound with a DataGrid.
Any help is most appreciated.
Thanks in advance