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
and here is where I call the selectmethod on a btn clickCode:[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; } }
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?Code:protected void BTNLogin_Click(object sender, EventArgs e) { ObjectDataSource1.Select(); }
Thanks!
oh my object datasource is bound the this dataobject with the parameters with values set to textboxes on the form


Reply With Quote