シフト開始とシフト終了に日時ピッカーを使用した Windows アプリケーションがあります。それらのタイミングをテーブルに挿入する必要があります。私のコードは:
if (comboBox1.SelectedIndex == 0 || comboBox1.SelectedIndex == 1 || comboBox1.SelectedIndex == 2 || comboBox1.SelectedIndex == 3 || comboBox1.SelectedIndex == 4 || comboBox1.SelectedIndex == 5 || comboBox1.SelectedIndex == 6 || comboBox1.SelectedIndex == 7 || comboBox1.SelectedIndex == 8 || comboBox1.SelectedIndex == 9 || comboBox1.SelectedIndex == 10 || comboBox1.SelectedIndex == 11 || comboBox1.SelectedIndex == 12 || comboBox1.SelectedIndex == 13 || comboBox1.SelectedIndex == 14 || comboBox1.SelectedIndex == 15 || comboBox1.SelectedIndex == 16)
{
string Query = " Insert into [ICPS].[dbo].[Cau reports]( [Name],[Date],[Shift Start],[Shift END ],[Overtime Start],[Overtime End],[Tasks Carried Out],[Normal ],[Overtime],[Normal 1],[Overtime1],[Comments],[Targets_(per hour)]) values ('" + this.textBox1.Text + "','" + this.Date.Text + "', CONVERT(VARCHAR(5),'" + this.SS.Text + "',108), '" + this.SE.Text + "','" + this.OS.Text + "','" + this.OE.Text + "','" + this.comboBox1.SelectedText + "','" + this.NT.Text + "','" + this.OT.Text + "','" + this.textBox2.Text + "','" + this.textBox3.Text + "','" + this.textBox4.Text + "','" + this.textBox5.Text + "' ) ;";
// string Query = " update [ICPS].[dbo].[Cau reports] set [Normal]='" + this.textBox7.Text + "',[Overtime]='" + this.textBox8.Text + "',[Normal 1]='" + this.textBox2.Text + "',[Overtime1]='" + this.textBox3.Text + "',[comments]='" + this.textBox4.Text + "',[Targets_(per hour)]='" + this.textBox5.Text + "'where [Tasks Carried Out] ='" + this.comboBox1.SelectedText + "'; ";
SqlConnection conDatabase = new SqlConnection(constring);
SqlCommand cmdDataBase = new SqlCommand(Query, conDatabase);
SqlDataReader myReader;
try
{
conDatabase.Open();
myReader = cmdDataBase.ExecuteReader();
MessageBox.Show("Saved");
while (myReader.Read())
{
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
しかし、私の出力は次のとおりです:01/01/1900 16:36(シフト開始とシフト終了の日付は必要ありません)。どんな助けでも本当にありがたいです.お願いします...