TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sathya Narayan
NA
155
65.5k
Condition is Not Satisfying
Feb 15 2014 3:10 AM
hi ,
I took attandance field in my table tbl_Attandance,so i need to satisfy the condition of the attandance out of 100.Its not satisfying..Wats the problem in this code .Can anyone help me
This is my Code.
private void SaveData()
{
int attendance = 100;
if (txtsn.Text == "")
{
MessageBox.Show("Select The Student Name");
txtsn.Focus();
}
else
if (cbosem.Text == "---Select Semister---")
{
MessageBox.Show("Select The Semister");
cbosem.Focus();
}
else
if (txtdep.Text == "")
{
MessageBox.Show("Select The Department");
txtdep.Focus();
}
else
if (cbosub.Text == "---Select Subject---")
{
MessageBox.Show("Select The Subject");
cbosub.Focus();
}
else
if (txtattnd.Text == "")
{
MessageBox.Show("Enter The Attandance");
txtattnd.Focus();
}
else
if (attendance >= 80)
{
MessageBox.Show("Eligible for The Exam ");
}
else if (attendance >= 75)
{
MessageBox.Show("Not Eligible for The Exam ");
}
else if (attendance == 40){
MessageBox.Show("Shortage Of Attandance");
}
else
{
MessageBox.Show("Do You Like To Insert Into Attandance Record?", "Save", MessageBoxButtons.YesNo);
SqlConnection con = new SqlConnection(connectionString);
try
{
string Query = "insert into tbl_attendance(studentid,semid,subjectid,attend)values('" + label15.Text + "','" + label6.Text + "','" + label5.Text + "','"+txtattnd .Text +"') ";
SqlCommand cmd = new SqlCommand(Query, con);
cmd.CommandText = Query;
con.Open();
int i = cmd.ExecuteNonQuery();
if (i > 0)
{
MessageBox.Show("Successfully Inserted...");
return;
}
}
catch
{
MessageBox.Show("Error in Connection");
}
Display();
clear(); //close the connection
con.Close();
GroupBox1.Enabled = false;
}
}
Reply
Answers (
5
)
doubt in adding data in database in c#
child table can not be updated