problem with type casting

R

Rajeev

Hi,

I am using a typed dataset ABC that contains a table Employee that
conatins a column EmployeeId and EmployeeName.

I want to select a row from Employee table from dataset ABC for which
the EmployeeName is "John"

what i am doing is :

I have declared a object of the Dataset say ABCObject

Now i have declared a variable of row type for the table Employee like
ReturnedRow = ABC.EmployeeRow

Now i am assigning the row that contains "john" in the dataset table
like

ReturnedRow = ABC.EmployeeRow(Select EmployeeName = "John")

Here i am getting the error that i need to type cast

But when i typecast to EmployeeRow, it says "can't typecast
EmployeeRow to EmployeeRow) - both r same

If i use

For each ReturnedRow in ABC.EmployeeRow.Rows
If .....
Next

Here also the get the same above error. Both the source and target
data tye is same, then also i don't know why it need to typecast and
when typecasting why it is giving error

Can anyone help me with this.

regards,
Rajeev
 
P

Phill W.

Rajeev said:
Here i am getting the error that i need to type cast

But when i typecast to EmployeeRow, it says "can't typecast
EmployeeRow to EmployeeRow) - both r same

/Are/ they?

Are both variables declared using the /same/ declaration of the class,
loaded from the /same/ assembly. If not, then they're totally
/different/ Types, as far as the Framework is concerned.

Compare these:

? ReturnedRow.GetType.ToString()
? ABC.EmployeeRow(Select ... ).GetType().ToString()
? ReturnedRow.GetType Is ABC.EmployeeRow(Select ...).GetType()

HTH,
Phill W.
 
B

Branco Medeiros

Rajeev wrote:
I am using a typed dataset ABC that contains a table Employee that
conatins a column EmployeeId and EmployeeName.

I want to select a row from Employee table from dataset ABC for which
the EmployeeName is "John"
Now i am assigning the row that contains "john" in the dataset table
like

ReturnedRow = ABC.EmployeeRow(Select EmployeeName = "John")
<snip>

I suppose the correct syntax would be:

Dim ReturnedRows() As EmployeeRow = _
ABC.Emploees.Select("EmployeeName = 'John'")

HTH.

Regards,

Branco.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top