I am making an application that will automatically fetch information from database and display it on a textbox based on date. So for example i want to fetch a latest article on feb 25,2016. How do i do that? i need help cus im kinda new to c# Any help would be gladly appreciated. Please help me.

1 Year
Discussion Span
Last Post by Tashia_1
 OleDbConnection cn = new OleDbConnection();
            cn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\`Hp\Desktop\PROGRAM1\notificationSystem\notificationSystem\Database.accdb";
            OleDbCommand cmd = new OleDbCommand();
            cmd.Connection = cn;
            cmd.CommandText = "select article from news where npublished = '" + metroDateTime1.Text + "' AND ntime = '" + label4.Text + "'";
            //AND ntime = '" + label4.Text + "'
            //Scalar executes the fetching of data

            var a = cmd.ExecuteScalar();
            //this statement gets the process of getting the data from the database to label          
            if (a != null)
                label1.Text = "" + a.ToString();
                //while in this statement is displaying the data inside the textbox
                metroTextBox2.Text = label1.Text;
            else if (metroTextBox2.Text != null)
                //SEND SMS PROCESS
            else if (metroTextBox2.Text == null)
                //REPEAT FETCH

I found a solution but have one problem, the code above works but its a manual fetch so i have to press a button everytime if i want to fetch, and i want to do it automatically and how would i do that?

Please help me on what should i do?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.