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
Venkatesh Shiga
NA
4
668
How to retrieve Distinct strings from comparing two Arrays?
Jan 22 2018 6:06 AM
I want to retrieve Absent student names from sql database. I have a Listbox in which i have Present student Rfid data (Something like 42 39 A0 11), I have stored the student details along with Rfid in database as nvarchar(1500) datatype.
Using the present stud id in list box i want to retrieve absent students name in an array.
I used NOT IN condition in where but i was not able to retrieve
Then i thought of using for loops to match the get the students who's id was not in the Listbox
But still I am losing the values and not getting proper absent students Id.
private
void
checkabst_Click(
object
sender, EventArgs e)
{
string
[] present =
new
string
[3];
string
[] absent =
new
string
[3];
string
[] allstd =
new
string
[3];
List<
string
> total =
new
List<
string
>();
using
(SqlConnection con =
new
SqlConnection(cs))
{
SqlCommand cmd =
new
SqlCommand(
"Select Rfid_Uid From Studetails"
, con);
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
while
(sdr.Read())
{
total.add(sdr[0].ToString());
}
allstd=total.toArray();
for
(
int
i=0;i
{
present[i] = listbox_present.Items[i].ToString();
}
bool
isfound =
false
;
for
(
int
i = 0; i < 3; i++)
{
isfound =
false
;
for
(
int
j = 0; j < present.Length; j++)
{
if
(allstd[i] == present[j])
{
isfound =
true
;
}
}
if
(!isfound)
{
MessageBox.Show(allstd[i]);
}
}
Stuck here from past few days.
I am getting Present as well as the absent student Ids in messagebox.
Reply
Answers (
3
)
Difference Between Arrays and Collections ?
display username and password connected?