I am trying to call the method with my code - behind which links to my business access layer and method From the click of the Data Access Layer login, I want to know if the data table gives a line of values, and if the user is redirected to my product page. The problem is that my method is not returning anything, so if nothing happens click the button Can anyone tell me what I have done? // Private zero log in the code () {// it joins the BA layer string usernameName = Convert.tostString (txtUser.Text); String Password = Convert ToString (txtPassword.Text); New ballogin () Valid user (username, password); } / / Method / Method in your Business Access Layer class (Public Zero) ValidateUser (String Username, String Password) // wasvoid {new GetUser (). GetUserpassword (username, password); }} // Code Data Access Layer Public Zero GetUserpassword (String Username, String Password) {DataSet myDataSet = new DataSet (); SqlCommand cmdvaliduser = New SqlCommand (); Cmdvaliduser.CommandText = "sp_userlogin"; Cmdvaliduser.CommandType = CommandType.StoredProcedure; Cmdvaliduser.Connection = TROPSConnection.GetConnection (); Cmdvaliduser.Parameters.AddWithValue ("@ userid", user name); Cmdvaliduser.Parameters.AddWithValue ("password @", password); Cmdvaliduser.Connection.Open (); SqlDataAdapter da = New SqlDataAdapter (); Datatable dt = new datatable (); Da.Fill (DT); Cmdvaliduser.ExecuteNonQuery (); Cmdvaliduser.Connection.Close (); } Protected Zero loginbetton_link (object sender, eventarges e) {try {login (); Datatable dt = new datatable (); If (dt.ows.Count & gt; 0) {Response.Redirect ("Products.spx"); }} Hold {console. WriteLine ("{0} was caught exception.", E); }}
You do not set up data adapters correctly You are filling up your datatelle, depending on the DT, empty data adapters - you should use
da = new SQLDataAdapter (CMDWiLuuser); But
But if I agree with Joel, you should submit the hacked values in your database.
Then rewriting your Getuserpassword () is called the check user password () and it has returned a boolean that the user / password is valid or invalid.
Set up your stored functionality so that you can pass the username and password in the hash, view it in the database and then return true / incorrect as the output variable from the stored procedure.
Comments
Post a Comment