J
jason
I've got this really simple table with two fields
book:
name varchar(50)
phone varchar(50)
and simple stored procedure jcp1:
ALTER procedure "jcp1"
@name varchar(50) AS
SELECT phone FROM book where name = @name
from ASP.NET I have no problem using the stored procedure as a
datasource to bind rows found into a datalist control.
As a test, I wanted to try and pull the result of the stored procedure
to a list from C# .. this code isn't exactly doing that, but i I
expected it to work:
TExecuteReaderCmd<string>(sqlCmd, TGeneratephone<string>, ref
userList);
foreach (string phonex in userList)
{
if (!userList.Contains(phonex))
{
Label1.Text = phonex;
userList.Add(phonex);
}
However this code failes to retreive anything or ever execute
Label1.Text = phonex; A watch of userList shows a count of 1 in
userList when it gets to this part.
If I remove the if (!userList.Contains(phonex)) condition as follows ,
I get a "collection was modified error" at the If line - it happens on
a subsiquent second pass throught the for loop. When I do this I can
see that Label1.Text gets set to a valid phonex before crashing.
//if (!userList.Contains(phonex))
//{
Label1.Text = phonex;
userList.Add(phonex);
//}
I know the above for loop does not make sense, but I was expecting it
to work and set Label1 to the last phone returing from the stored
procedure.
book:
name varchar(50)
phone varchar(50)
and simple stored procedure jcp1:
ALTER procedure "jcp1"
@name varchar(50) AS
SELECT phone FROM book where name = @name
from ASP.NET I have no problem using the stored procedure as a
datasource to bind rows found into a datalist control.
As a test, I wanted to try and pull the result of the stored procedure
to a list from C# .. this code isn't exactly doing that, but i I
expected it to work:
TExecuteReaderCmd<string>(sqlCmd, TGeneratephone<string>, ref
userList);
foreach (string phonex in userList)
{
if (!userList.Contains(phonex))
{
Label1.Text = phonex;
userList.Add(phonex);
}
However this code failes to retreive anything or ever execute
Label1.Text = phonex; A watch of userList shows a count of 1 in
userList when it gets to this part.
If I remove the if (!userList.Contains(phonex)) condition as follows ,
I get a "collection was modified error" at the If line - it happens on
a subsiquent second pass throught the for loop. When I do this I can
see that Label1.Text gets set to a valid phonex before crashing.
//if (!userList.Contains(phonex))
//{
Label1.Text = phonex;
userList.Add(phonex);
//}
I know the above for loop does not make sense, but I was expecting it
to work and set Label1 to the last phone returing from the stored
procedure.