1jaws
asked on
easy for experts.
I have a sp that at the end I have this code
updated is bit and returnMessage is varchar
select @updated as updated, @returnMessage as message
but then on cs code I am using Execute Reader and using while loop to get the value of the updated and the message but gives me error saying {updated}
I say like this on while loop after executing reader
if (bool.Parse(reader["update d"].ToStri ng()) == false) -->> Catches error here.
...blah blah...
what am I doing wrong..?
I am trying to find the value of the updated and the of course message.
updated is bit and returnMessage is varchar
select @updated as updated, @returnMessage as message
but then on cs code I am using Execute Reader and using while loop to get the value of the updated and the message but gives me error saying {updated}
I say like this on while loop after executing reader
if (bool.Parse(reader["update
...blah blah...
what am I doing wrong..?
I am trying to find the value of the updated and the of course message.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if (bool.Parse(reader["update d"].ToStri ng()) == false)
-->
if (reader["updated"].ToStrin g()) == "0") ....
-->
if (reader["updated"].ToStrin
ASKER
no.. cannot convert string to bool.
in my post, I suggested you to use:
f (reader["updated"].ToStrin g()) == "0") ....
probably from db, it is coming as 0, 1, not true or false
f (reader["updated"].ToStrin
probably from db, it is coming as 0, 1, not true or false
ASKER
yes I know but it gives error saying it cannot convert string to bool...
and I guess right syntax is Boolean.Parse(...)
ASKER
that didnt work either .. this worked if (reader["updated"].ToStrin g() == "0") but it is giving me IndexOutOFRangeException {updated}
if (reader["updated"].ToStrin g()) == "0") ....
in my last 2-3 posts I suggested NOT using bool.parse, and you keep saying boolean parse errors, AI am confused now... anyway, I guess you finally started using
if (reader["updated"].ToStrin g() == "0")
;) now where do you get this index error? it should be somewhere else...
in my last 2-3 posts I suggested NOT using bool.parse, and you keep saying boolean parse errors, AI am confused now... anyway, I guess you finally started using
if (reader["updated"].ToStrin
;) now where do you get this index error? it should be somewhere else...
ASKER
I am getting that index error because my sp I have three select statements, it is thinking first one which has no column name, thats why it is throwing error. Question is how can I ignore first two select statement but rather have the third select stament which contains, update and message column names see below
my results looks like this when I executed my sp
No column Name
1
ID
12232
updated message
1 it is updated
as you can see I am getting three different resutls. but when I am reading from cs code I just want third result... Thats all I need.
my results looks like this when I executed my sp
No column Name
1
ID
12232
updated message
1 it is updated
as you can see I am getting three different resutls. but when I am reading from cs code I just want third result... Thats all I need.
how can we say something in this case?
you should post (at least related parts of) sp code and the vb/c# code to get the data from your sp
you can replace select statements in your sp
so updated will be first thing you read from cs?
you should post (at least related parts of) sp code and the vb/c# code to get the data from your sp
you can replace select statements in your sp
so updated will be first thing you read from cs?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
YEs thank you!
ASKER
lblChange.Text = reader["message"].ToString