c# - text entered in uppercase during login still gives successful login -


i have login page windows application in c#.even if enter username , password in uppercase i.e caps on still login successful.

this should not case, enteries in database in lower case.

public partial class frmlogin : form {     sqlconnection con = new sqlconnection("data source=th07l019;initial catalog=procurement;integrated security=true");     datatable dt = new datatable();     sqlcommand cmd = new sqlcommand();     sqldataadapter adp = new sqldataadapter();       public frmlogin()     {         initializecomponent();     }      private void form1_load(object sender, eventargs e)     {         cmd.connection = con;     }      private void button1_click(object sender, eventargs e)     {         con.open();         cmd.commandtext = "select * login username='" + txtusername.text + "' , password='" + txtpassword.text + "'";         adp.selectcommand = cmd;         adp.fill(dt);         if (dt.rows.count > 0)         {             frmmain main = new frmmain();             main.show();         }         else         {             messagebox.show("please enter correct name , passowrd", "error", messageboxbuttons.ok, messageboxicon.error);             txtusername.clear();             txtpassword.clear();         }         con.close();     } } 

how solve problem

leaving aside fact storing passwords in plain text worst idea ever security standpoint, , fact users can execute sql injection attack on database entering "special" password+, reason code ignores caps rdbms has case-insensitive string comparison.


+ imagine (do not try) password string looks this:

';drop table login-- 

do know what happen? in addition,

';select 1;-- 

would become "master password", letting login else.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -