{
If (textBox1. Text=="" | | textBox2. Text==" "| | comboBox1. Text==" ")
{
MessageBox. Show (" please check and enter again ", "prompt", MessageBoxButtons. OK, MessageBoxIcon. Warning).
Return "1";
}
If (comboBox1. Text=="students")
{
String SQL="select * from Students where Name='" + textBox1. Text +"' and PassWord='" + textBox2. Text + "' ";
Dao Dao=new Dao ();
IDataReader Dr=dao. Read (SQL);
If (Dr. Read ())
{
Return "students";
}
The else
{
Return "1";
}
}
If (comboBox1. Text=="teacher")
{
String SQL="select * from head where Name='" + textBox1. Text +"' and PassWord='" + textBox2. Text + "' ";
Dao Dao=new Dao ();
IDataReader Dr=dao. Read (SQL);
If (Dr. Read ())
{
Return "teacher";
}
The else
{
Return "1";
}
If (comboBox1. Text=="administrator")
{
If (textBox1. Text=="admiin" & amp; & TextBox2. Text=="admin")
{
Return "administrator";
}
The else
{
Return "1";
}
}
Return "1";
}
}
When doing the simple student information management system appear such errors, which members can help solve?
CodePudding user response:
Check your the outermost layer of the if, if (comboBox1. The Text is not equal to students is not equal to the teacher, what it returnsCodePudding user response:
A return valueCodePudding user response:
private string the login ()
{
//if (textBox1. Text=="" | | textBox2. Text==" "| | comboBox1. Text==" ")
//{
//MessageBox. Show (" please check and enter again ", "prompt", MessageBoxButtons. OK, MessageBoxIcon. Warning).
//return "1";
//}
If (comboBox1. Text=="students")
{
String SQL="select * from Students where Name='" + textBox1. Text +"' and PassWord='" + textBox2. Text + "' ";
Dao Dao=new Dao ();
IDataReader Dr=dao. Read (SQL);
If (Dr. Read ())
{
Return "students";
}
The else
{
Return "1";
}
}
If (comboBox1. Text=="teacher")
{
String SQL="select * from head where Name='" + textBox1. Text +"' and PassWord='" + textBox2. Text + "' ";
Dao Dao=new Dao ();
IDataReader Dr=dao. Read (SQL);
If (Dr. Read ())
{
Return "teacher";
}
The else
{
Return "1";
}
If (comboBox1. Text=="administrator")
{
If (textBox1. Text=="admiin" & amp; & TextBox2. Text=="admin")
{
Return "administrator";
}
The else
{
Return "1";
}
}
Return "1";
}
MessageBox. Show (" please check and enter again ", "prompt", MessageBoxButtons. OK, MessageBoxIcon. Warning).
Return "1";
}