add results to dataset

S

Steve

Ok, I hit a wall and I'm stuck. I have a web form that has a textbox were
the user can enter in 1 to many usernames, then the user has to validate the
user to make sure the user exists. I have a stored procedure that can only
take one username at a time, so I need to keep calling this stored procedure
with all of the usernames in the textbox( i have this portion working). The
issue I'm running into is that only the data for the last username passed to
the stored procedure is being passed back so if I enter in

JSmith, SLong, SHenry,

I'm only getting the details for SHenry, though I need to store and use the
details for all 3 users so I can add them to the user table.

so when I click the add buttong, its storing:
JSmith, SLong, SHenry in the user column of the table BUT storing SHenry,
phone number, email address etc. I need a row for each user with their own
information


So I either need somehow to keep adding it to the existing dataset or
somethign.

any suggestions on how to do this?
 
A

Alexey Smirnov

Ok, I hit a wall and I'm stuck. I have a web form that has a textbox were
the user can enter in 1 to many usernames, then the user has to validate the
user to make sure the user exists. I have a stored procedure that can only
take one username at a time, so I need to keep calling this stored procedure
with all of the usernames in the textbox( i have this portion working). The
issue I'm running into is that only the data for the last username passed to
the stored procedure is being passed back so if I enter in

JSmith, SLong, SHenry,

I'm only getting the details for SHenry, though I need to store and use the
details for all 3 users so I can add them to the user table.

so when I click the add buttong, its storing:
JSmith, SLong, SHenry in the user column of the table BUT storing SHenry,
phone number, email address etc. I need a row for each user with their own
information

So I either need somehow to keep adding it to the existing dataset or
somethign.

any suggestions on how to do this?

Can we see the code of the stored procedure?
 
S

Steve

the stored procedure is actually a select statement that calls a view which
is doing a select, joins, etc on tables.
but the stored procedure is

select * from vGetUserInformation where ID = @id

and the view is doing all of the work
 
A

Alexey Smirnov

the stored procedure is actually a select statement that calls a view which
is doing a select, joins, etc on tables.
but the stored procedure is

select * from vGetUserInformation where ID = @id

and the view is doing all of the work

Well, then it's something the code I guess... Need to see it :)
 
A

Alexey Smirnov

need to see what? the .net code or the SQL code?

Steve, you said that
issue I'm running into is that only the data for the last username passed to
the stored procedure is being passed back

So I think that the problem is somewhere either in the .net code which
runs the stored procedure, or in the stored procedure itself. If you
think that the stored procedure is ok then we should check the code
which calls the stored procedure. Maybe you call it only once, or
something like this... ??
 
S

Steve

i have something like

string userList = txtUsername.txt;
string[] user= userList.split(',');

foreach(String u in users)
{
DataSet dsUsers = new DataSet();
dsUsers = GetUserDetails(u);
}

//this calls the datalayer which houses the stored procedure
Public DataSet GetUserDetals(string userName)
{
DataSet ds = new DataSet();
ds = UserInformation.UserDetails(userName);
return ds;
}
 
A

Alexey Smirnov

i have something like

string userList = txtUsername.txt;
string[] user= userList.split(',');

foreach(String u in users)
{
DataSet dsUsers = new DataSet();
dsUsers = GetUserDetails(u);

}

What do you do with dsUsers after that?
 
S

Steve

I'm reading through it to see if the users in the textbox are in the
returned dataset from my stored procedure
Alexey Smirnov said:
i have something like

string userList = txtUsername.txt;
string[] user= userList.split(',');

foreach(String u in users)
{
DataSet dsUsers = new DataSet();
dsUsers = GetUserDetails(u);

}

What do you do with dsUsers after that?
 
A

Alexey Smirnov

I'm reading through it to see if the users in the textbox are in the

Okay, let's test it...

You have JSmith, SLong, SHenry in the txtUsername

So

string userList = txtUsername.txt;
string[] user= userList.split(',');

foreach(String u in users)
{
// user #1: JSmith

DataSet dsUsers = new DataSet();
dsUsers = GetUserDetails(u); // u = JSmith

// and now, what do you do with the data?
}

If database has that JSmith in the vGetUserInformation table, then you
should get some data from it

select * from vGetUserInformation where ID = @id // @id = 'JSmith'

if dsUsers is not empty than the error somewhere in the .net code
after the one you sent above.
 
A

Alexey Smirnov

P.S.

string[] user= userList.split(',');

returns

'JSmith'
' SLong' <-- with the leading space
' SHenry' <-- with the leading space

could be a problem, if you don't trim()
 

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