Oladotun Obileye

Oladotun Obileye

  • NA
  • 98
  • 19.3k

How to merge two database together to datagrid c# winsform

May 30 2019 1:49 AM
Good day everyone please i am working on c# windowsform applicaton for loan i want to join two database base on a particular column. i have  two database(employement,loanform) please i want to join the two of them to a new table so there will not be duplicate colums)
 
database employementform(1st database)
 id          employementnumber      fullname      age      
1            ts/02/001                         adedoyin     40
2            ts/02/003                          chisom        25
3            ts/02/012                           femi            44
 
 
database loanform(2nd database)
id          employementnumber      amountofloan         percent         totalamount
1           ts/02/003                          10000                     10                  100000
2           ts/02/003                           2500                        10                2750
3            ts/02/01                             1200                      10                 1320
4            ts/02/012                            60                        10                     66
 
i want to join them on a new database to show on a datagridview and i want it to be like this:
database join
 id     employementnumber      fullname        age    amountofloan     percent    totalamount
 1      ts/02/003                          adedoyin     40         10000                10         100000
2        ts/02/003                         adedoyin     40          2500                 10            2750
3        ts/02/01                             chisom        25        1200                  10           1320
 
 
this is my code
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\odt\Documents\Loanapp.mdf;Integrated Security=True;Connect Timeout=30");
DataTable dt = new DataTable();
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from loanform,Registrationform";
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(cmd);
 
please help thanks. 

Answers (2)