Click to See Complete Forum and Search --> : Help with Object Data Source


maitopoika
April 13th, 2009, 02:15 PM
I am creating a simple login function using an objectdatasource.
How can I check how many rows are selected after I run the query?
here is my dataobject

[DataObject(true)]
public static class MembershipDB
{
[DataObjectMethod(DataObjectMethodType.Select)]
public static IEnumerable CheckMembership(string username, string password)
{
SqlConnection con = new SqlConnection(ConnectionString.GetConnectionString());
string sel = "SELECT * from Membership WHERE Membership.UserName = @ username AND Membership.Password=@password";
SqlCommand cmd = new SqlCommand(sel, con);
cmd.Parameters.AddWithValue("userName", username);
cmd.Parameters.AddWithValue("password", password);
con.Open();
SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
return dr;

}
}

and here is where I call the selectmethod on a btn click

protected void BTNLogin_Click(object sender, EventArgs e)
{
ObjectDataSource1.Select();

}


I just need to make sure the username and password that is sent is in the database, so how do i see if the rows affected = 0?
Thanks!
oh my object datasource is bound the this dataobject with the parameters with values set to textboxes on the form