If you debug the code you'll see which line of code is causing the error. Then you'll see what the problem is with the string. However, I don't see anything in the code you have posted that would cause that error so again, pay attention to where the error tells you it is happening.
Then you'll also want to change your code to use parameters.
For example:
cmd = new SqlCommand("select * from login where username=@userName and password=@password and role='admin01'", con);
cmd.Parameters.AddWithValue("@userName", txtusername.Text);
cmd.Parameters.AddWithValue("@password", txtpassword.Text);