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
J Vs
NA
52
3k
ACCESS Database - Check if User is in DB if not then alert
Aug 13 2019 3:00 AM
Please see my script and help. IT HAS TO BE ACCESS DB and NOT SQL.
private
void
tableqry() {
try
{
connection.Open();
OleDbCommand command =
new
OleDbCommand();
command.Connection = connection;
string
query =
"select *,"
+
"(Course1 + Course2 + Course3 + Course4+ Course5 + Course6 + Course7 + Course8 + Course9 + Course10) / 10 AS AvgMark "
+
"from Students WHERE Firstname LIKE '"
+ tbsearchid.Text +
"' OR "
+
"ID1 like '"
+ tbsearchid.Text +
"'"
;
command.CommandText = query;
OleDbDataReader reader = command.ExecuteReader();
while
(reader.Read()) {
tbFname.Text = reader[
"Firstname"
].ToString();
tbLname.Text = reader[
"Lastname"
].ToString();
string
course1Text = reader[
"Course1"
].ToString(), course2Text = reader[
"Course2"
].ToString(),
course3Text = reader[
"Course3"
].ToString(), course4Text = reader[
"Course4"
].ToString(),
course5Text = reader[
"Course5"
].ToString(), course6Text = reader[
"Course6"
].ToString(),
course7Text = reader[
"Course7"
].ToString(), course8Text = reader[
"Course8"
].ToString(),
course9Text = reader[
"Course9"
].ToString(), course10Text = reader[
"Course10"
].ToString();
tbmulti.Text =
"Course1: "
+ course1Text + Environment.NewLine +
"Course2: "
+ course2Text +
Environment.NewLine +
"Course3: "
+ course3Text + Environment.NewLine +
"Course4: "
+ course4Text +
Environment.NewLine +
"Course5: "
+ course5Text + Environment.NewLine +
"Course6: "
+ course6Text +
Environment.NewLine +
"Course7: "
+ course7Text + Environment.NewLine +
"Course8: "
+ course8Text +
Environment.NewLine +
"Course9: "
+ course9Text + Environment.NewLine +
"Course10: "
+ course10Text;
int
[] marks =
new
int
[10] {
Convert.ToInt32(reader[
"Course1"
]), Convert.ToInt32(reader[
"Course2"
]),
Convert.ToInt32(reader[
"Course3"
]), Convert.ToInt32(reader[
"Course4"
]),
Convert.ToInt32(reader[
"Course5"
]), Convert.ToInt32(reader[
"Course6"
]),
Convert.ToInt32(reader[
"Course7"
]), Convert.ToInt32(reader[
"Course8"
]),
Convert.ToInt32(reader[
"Course9"
]), Convert.ToInt32(reader[
"Course10"
])
};
int
avgmarks = sumAverageElements(marks, marks.Length);
if
(avgmarks <= 40) {
tbrate.Text =
"Fail"
;
}
else
if
(avgmarks <= 59) {
tbrate.Text =
"Pass"
;
}
else
if
(avgmarks <= 79) {
tbrate.Text =
"Good"
;
}
else
if
(avgmarks <= 100) {
tbrate.Text =
"Excellent"
;
}
tbhighmark.Text = marks.Max().ToString();
tblowmark.Text = marks.Min().ToString();
tbCourseAvg.Text = avgmarks.ToString();
}
connection.Close();
}
catch
(Exception ex) {
MessageBox.Show(
"Error "
+ ex);
}
}
Reply
Answers (
3
)
How to use Datagridview 1st row for filter purpose.
Multi Text Box subtraction