Click here to Skip to main content
15,894,955 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi , every one:
i am using a attendance concept in my windows application, one table is have all name in the concern all details are filled by admin. Another table is filled by entry of employee in to company. now i have to seperate presented list and absented list.
i am showing 2 different gridview, 1 for present and another one for absent,
i am using a query in presented table:
conn.Open();
            DataTable dtusers = new DataTable();
            
            SqlDataAdapter da = new SqlDataAdapter("select name,tdate,timein from daily_att where tdate='"+tdat+"' ", conn);

            SqlCommandBuilder cmd = new SqlCommandBuilder(da);
            da.Fill(dtusers);
            grd_pres_rep.DataSource = dtusers;
            grd_pres_rep.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
            conn.Close();

now how can i list out absented employee in my second gridview?
Posted
Comments
CHill60 10-May-13 9:20am    
Whichever solution below you choose please consider using parameterized queries to protect yourself from sql injection attacks. They also make your code neater and more efficient. http://www.dotnetperls.com/sqlparameter[^]

try like this ..
conn.Open();
DataTable dtusers = new DataTable();
            
SqlDataAdapter da = new SqlDataAdapter("select name from admin_table where name not in (select name from daily_att where tdate='"+tdat+"' ) ", conn);
 
SqlCommandBuilder cmd = new SqlCommandBuilder(da);
da.Fill(dtusers);
grd_absent_rep.DataSource = dtusers;
grd_absent_rep.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
conn.Close();
 
Share this answer
 
Use:

select * from master_table where id not in (select id from daily_att);

where id is the primary key for the tables
 
Share this answer
 
Comments
srigates 11-May-13 1:33am    
it not working
srigates 11-May-13 1:41am    
select Emp_name from nat_emp_det where Emp_name not in (select name from daily_att )

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900