c# - Login Form trouble -


i wrote following code log in application using c# , linq. connected sql service oriented database have created in visual studio. problem having 1 not understand , hoping can me here. have created 2 message boxed try see output of code buy not getting it.

if great!

public bool userlogin(string user, string pass) {     var database = new exampledataset();      var query = employee in database.employee         (employee.employeeid.tostring() == employee.tolower() && employee.password == pass)         select employee;      if (query.count() != 0)     {         return true;         messagebox.show("you logged in");     }      return false;     messagebox.show("you not logged in"); }  private void cmdlogin_click(object sender, eventargs e) {     string user = (txtuser.text);     string pass = (txtpass.text);     userlogin(user, pass); } 

from code wrote, seems problem compare string representation of employee employeeid property employee.employeeid.tostring() == employee.tolower(). line return false unless override tostring() method of employee class return property employeeid (which presume didn't). try instead (assuming parameter user contains name of user):

using(var dataset = new exampledataset()) {     var loggedin = dataset.employee.any(e=>e.username == user && e.password == pass);     var message = loggedin ? "you logged in" : "you not logged in";     messagebox.show(message);     return loggedin; } 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -