Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Webservices + DataSets + Queries (longish)

Status
Not open for further replies.

KevoMee

Technical User
Apr 30, 2002
72
IE
Ok I have a question:

I have written a Webservice that will take an entire table (users) from my database and return it to whatever aspx page is calling it.

I want it so that when a user logs in I can check his/her details against this dataset, so basically I want to do a select statement on the dataset. Is this possible? Or will I have to create a totally new WebService in this class to do a select statement on the database again? If so wouldn't that defeat the whole purpose given that I would have to access the database for every individual statement.

I have a feeling that I'm missing out on something small but important here.

I have done all this in .NET studio. I will give some snipets of my code:


// sqlSelectCommand1

this.sqlSelectCommand1.CommandText = "SELECT username, lastname, firstname, location, email FROM users";

this.sqlSelectCommand1.Connection = this.sqlConnection1;

Would I be right in saying that this is the basic select command? And I can change this however I see fit? e.g.

this.sqlSelectCommand1.CommandText = "SELECT username, lastname, firstname, location, email FROM users WHERE username = @username";

Would that be right? If so how exactly would I then implement it as a web service?

See the thing is that I look at the above code and see that I am accessing directly to the database which is not what I want to do, I would prefer to access the dataset instead.

would I be correct in just doing this as a select command:

[WebMethod]
public user_data GetUser(String username)
{
user_data users = new user_data(); //Don't know if I need this line?

sqlDataAdapter1.Fill(users); //Don't know if I need this line?

sqlDataAdapter1.Select(username);
return users;
}


I got most of this from the sample in .NET :

[WebMethod]
public user_data GetUsers()
{
user_data users = new user_data();
sqlDataAdapter1.Fill(users);
return users;
}

This basically returns the whole table where user_data is the datagrid(or set?) of my user table.

I would be much appreciative if anyone out there could help me this. I have been mucking about and reading about this for the last week or so and I am really starting to get very very frustrated. If anyone wants to look at the project or anything I could send it to them aswell.

Again, thanks alot people.
 
[WebMethod]
public user_data GetUser(String username)
{
user_data users = new user_data(); //Don't know if I need this line?

sqlDataAdapter1.Fill(users); //Don't know if I need this line?

sqlDataAdapter1.Select(username);
return users;
}

OK, that can be ignored, I copped onto how to get the select statement str8 from the database, but I'm wondering if it would be better to get a particular record from the dataset of the table rather than the table in the database? If so would anyone know how to do this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top