Hi; I am trying to check if someone is admin or not with a simple login form, my login works but when i try to check if admin or not that if statement doesn't work. I have a table with 3 column with username, password and type. I want to check if in the type column it writes Admin or not. Here is my code:
private void button1_Click ( object sender , EventArgs e ) { SqlConnection baglanti = new SqlConnection ( @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Mehmet\Documents\Visual Studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Database1.mdf;Integrated Security=True;User Instance=True;" ); SqlDataAdapter adabtor = new SqlDataAdapter ( "select Type from Log_In where Username='" + UserNametextBox1.Text + "' and Password = '" + PasswordtextBox2.Text + "'",baglanti); DataTable tablo = new DataTable(); adabtor.Fill(tablo); if ( tablo.Rows.Count == 1 ) { logInToolStripMenuItem.Enabled = false; logOutToolStripMenuItem.Enabled = true; LogInpanel1.Visible = false; Aboutpanel2.Visible = true; //MessageBox.Show ( tablo.Rows [ 0 ] [ 0 ].ToString () ); i use this to see what returns from this code, and code returns the correct value like Admin in this case, i also tryed to change Admin to 1, nothing changed if ( tablo.Rows [ 0 ] [ 0 ].ToString () == "Admin" ) { addAUserToolStripMenuItem.Visible = true; MessageBox.Show ( "haydi" ); } } else MessageBox.Show ( "Username or Password is wrong." ); }