Oladotun Obileye

Oladotun Obileye

  • NA
  • 98
  • 19.4k

how to retreive specific data from database in c# winsform

May 30 2019 8:10 AM
Good day everyone please i want to retreive data from a database base on a specific value.
 
i have a database table which has a column loanapprove
 
ID NAME                    EMAIL                             LOANAPPROVE
1 kunle                       [email protected]                 pending
2 chisom                    [email protected]                   approved
3 Dami                          [email protected]           Denied
4 Hausa                       [email protected]              Denied
5 jones                          [email protected]           Denied
6 Alfred                       [email protected]           Approved.
 
i want to select all the data that the column loanapprove = approved to a datagridview
 
this is my code
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\odt\Documents\Loanapp.mdf;Integrated Security=True;Connect Timeout=30";
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "select * FROM loanapproval where loanapprove=@empno";

Answers (3)