Israel

Israel

  • 705
  • 1.3k
  • 216.4k

Need a intelligente rotation...

Dec 18 2014 12:38 PM
Hi
I have a very small table with 4 records:

Date             Name  operA   OperB
01/12/2014    Salam       1            2
01/12/2014    Shandi       5           3
01/12/2014    Eva           2           0
02/12/2014    Shamba     7           4
02/12/2014    Kali           1           1

Then I have four (4) textboxes and one Button:
txtDate, txtName, txtOperA, txtOperB and a btnSave
What I need?
When I click to btnsave all records should appear on thoses textboxs: name, opera and operB in other. For example, the first to appear it's "Salam" in txtName, the "1" in txtOperA and the "2" in txtOperB. After that Shandi with his own datas and so one. In conclusion, from the first record to the last one. Just when I make a filter for a specific date. That all!
See what I had tried… But not that all (I need the rotation's code):

To search date:
private void SearchDate_Click(object sender, EventArgs e)
        {
            string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dir1\\\app_data\data.mdb;Persist Security Info=False";
            OleDbConnection sqlCon = new OleDbConnection(connectionString);
            sqlCon.Open();
            string commandString = "select * from operation where date='" + txtDate.Text + "'";
            OleDbCommand sqlCmd = new OleDbCommand(commandString, sqlCon);
            OleDbDataReader read = sqlCmd.ExecuteReader();
            if (read.HasRows)
            {
                while (read.Read())
                {
                   txtDate.Text = read["date"].ToString(); 
                   txtName.Text = read["A"].ToString(); 
                   txtOperA.Text = read["B"].ToString(); 
                   txtOperB.Text = read["C"].ToString(); 
                }
            }
            else
            {
                MessageBox.Show("A record with this date " + codigoBarraConsStocks.Text + " doesnt exist. Sorry!");
            }
            read.Close();
            sqlCon.Close();
        }

With this codes its will ONLY search the record but NEVER show one by one on these texboxes.
Many thanx in advance.

Answers (3)