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
Sousa Pambo
NA
92
23.9k
CHECK A LISTVIEW WITH A SPECIFIC DATA
Mar 3 2015 3:43 PM
HI, I NEED A HELP WITH MY CODE. IT WAS WORKING PERFECTLY. IT'S TO CHECK A LISTVIEW BY THE SPECIFIC DATA FROM SQL DATABASE AND BY THE SPECIFIC STUDENT ID. BUT NOW IT'S IGNORING A ID, I DON'T KNOW IF MY QUERY IS NOT OK. YOU MAY SEE MY CODE BELOW.
public string DocExist(string doc)
{
string sql = "Select DocDescr From tbAlunoDoc where DocDescr ='" + doc + "'";
using (SqlConnection myconn = new SqlConnection(con.stringConexaoRH()))
{
try
{
myconn.Open();
using (SqlCommand comand = new SqlCommand(sql, myconn))
{
SqlDataReader dtreader = comand.ExecuteReader();
{
if (dtreader.Read())
{
return dtreader["DocDescr"].ToString();
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
return "-----";
}
public void CheckDocs(ListView ls, string ID) // to check a listview if a doc exist in the first method, but it ignoring a ID it takes all the docs doesn't exist ........//at the another table
{
string docmt = "";
string sql = "Select distinct id, descricao, idAlunoDoc from tbDocs, tbAlunoDoc where idAlunoDoc ='" + ID + "'";
ls.Items.Clear();
ListViewItem lst = new ListViewItem();
using (SqlConnection myconn = new SqlConnection(con.stringConexaoRH()))
{
try
{
myconn.Open();
using (SqlCommand comand = new SqlCommand(sql, myconn))
{
SqlDataReader dtreader = comand.ExecuteReader();
{
while (dtreader.Read())
{
lst = ls.Items.Add(dtreader["id"].ToString());
docmt = DocExist((dtreader["descricao"]).ToString());
if (docmt == "")
{
//got = 1;
lst.ForeColor = Color.Black;
}
else
{
//got = 2;
lst.ForeColor = Color.OrangeRed;
lst.Checked = true;
}
lst.SubItems.Add(dtreader["descricao"].ToString());
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
_________________
form
AlDal.CheckDocs(this.lstVwDocs, this.tbRefCadastro.Text);
I hope you get the point and help me because i'm done.
Reply
Answers (
3
)
random numbers in c
insert images into sql