Click here to Skip to main content
15,500,452 members

Comments by Member 11649391 (Top 1 by date)

Member 11649391 30-May-15 2:03am View     CRLF
I have join 5 tables how to use inner join query for joining five tables in c# using ms access database? this is my code try { OleDbConnection conn = new OleDbConnection(); conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\BS(CS)-6A\BS(CS)-6A\Database Managment System\Student Managment Project\School_Database\School_Managment_System.accdb; Persist Security Info=False;"; conn.Open(); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = conn; // string query = "select s.std_id, s.std_name, s.std_fname, s.std_phone, s.std_address, f.fee_paid, f.balance, f.fee_month, f.fee_year from std_info s join std_fees f on s.std_id = f.std_id"; string query = @"select *from (std_info inner join std_fees on std_info.std_id = std_fees.std_id), (inner join fees on fees.fee_id = std_fees.fee_id),(inner join class on class.class_id = fees.class_id)"; cmd.CommandText = query; OleDbDataAdapter da = new OleDbDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); dataGrid1.DataSource = dt; conn.Close(); } catch (Exception ex) { MessageBox.Show("Error" + ex); }