![]() ![]() ![]() ![]() |
|||||
|
|||||
樓主 資料庫新手 ![]()
![]() |
{ timer2.Interval = 10000; timer2.Enabled = true; if (textBox2.TextLength >= 4 && timer2.Enabled == true) { try { oleDbConnection1.Open(); string s; s = "update Processing set 加工完成='" + DateTime.Now + "' where 產品編號='" + textBox2.Text + "'"; oleDbCommand1.CommandText = s; oleDbCommand1.ExecuteNonQuery(); //我嘗試很很多次 以下程式似乎都沒有運行到 我甚至將textBox2.Text = null;的值放下去 就連這行程式也沒有執行 string g; dataGridView1.CurrentCell = dataGridView1[1, q]; DateTime time = Convert.ToDateTime(dataGridView1.CurrentCell.Value); dataGridView1.CurrentCell = dataGridView1[2, w]; DateTime time2 = Convert.ToDateTime(dataGridView1.CurrentCell.Value); TimeSpan ts = time2 - time; dataGridView1.CurrentCell = dataGridView1[0, a]; string b = Convert.ToString(dataGridView1.CurrentCell.Value); g = "update Processing set 工時='" + ts + "' where 產品編號='" + b + "'"; oleDbCommand1.CommandText = g; oleDbCommand1.ExecuteNonQuery(); textBox2.Text = null; } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { timer2.Enabled = false; oleDbConnection1.Close(); } } } 真的看不懂了 前輩們幫我看看 我上面註解的解說 但是 到了我輸入第二次的值後 上一列的g = "update Processing set 工時='" + ts + "' where 產品編號='" + b + "'"; 工時欄位 就出現了我要的值 但要操作兩次 很奇怪
搜尋相關Tags的文章:
[ c#資料庫程式有問題求救 ] ,
本篇文章發表於2017-08-29 17:04 |