How to access data yearly from DB in C# ?

Ads
 

How to access data yearly from DB in C# ?

how to access data yearly from database in C#.

I have code but i m not able to retrieve data yearly from DB table.

string date1 = dateTimePicker1.Value.Date.ToString("dd/MMM/yyyy");

        OleDbConnection con = new OleDbConnection(constr);
        DataSet ds = new DataSet();
        con.Open();
        String query7 = "SELECT unique_id as Student_ID,payment FROM fee" + ses + " where date1='" + date1 + "' and payment>0 order by unique_id ";
        OleDbDataAdapter da = new OleDbDataAdapter(query7, con);
        da.Fill(ds, "fee"+ses);
        dataGridView1.AutoGenerateColumns = true;
        dataGridView1.DataSource = ds;
        dataGridView1.DataMember = "fee" + ses;
        con.Close();
View Answers

September 23, 2014 at 12:29 AM

Use parameter with query string. see sample code.

String query7 = "SELECT unique_id as Student_ID,payment FROM fee" + ses + " where [email protected] and payment>0 order by unique_id ";
OleDbDataCommand cmd = new OleDbDataCommand(query7 );
cmd.parameters.addwithvalue("@date1",date1);
OleDbDataAdapter da = new OleDbDataAdapter(cmd, con);

Ads









Related Tutorials/Questions & Answers:

Ads