특정 보고서를 인쇄 할 때 추적 할 수 있도록 datetimes 그룹을 저장하는 응용 프로그램을 작성하고 있습니다. 이 보고서는 datetimes가있는 두 번째 테이블의 정보로 구성됩니다. 첫 번째 테이블의 마지막 datetime 뒤에있는 레코드로 datagridview를 채우도록 보고서를 가져 오려고합니다.C# datetime 값과 SQL Server Compact 4 datetime 비교
첫 번째 테이블을 '배달 용지'라고하며,이 테이블은 과거 인쇄 날짜를 저장합니다. 두 번째 테이블은 'joblog'라고하며 이전 작업 항목의 레코드를 저장합니다.
프로그램을 실행하면 잘 작동하고 마지막 날짜 이후 모든 레코드가있는 gridview가 채워지지만 정제되지는 않습니다. 날짜가 아닌 날짜 이후에 채워집니다. 두 번째로 gridview를 채우는 쿼리가 필요합니다 ....
DateTime lastDeliveryDate;
private void getLastDelivery() // Sets global variable lastDeliveryDate to the last timestamp entered in the deliverylog table
{
openLogConnection();
try
{
command = new SqlCeCommand("SELECT TOP 1 * FROM deliverylog ORDER BY Id DESC", logConn);
drLogSet = command.ExecuteReader();
while (drLogSet.Read())
{
lastDeliveryDate = Convert.ToDateTime(drLogSet["Timestamp"]);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
logConn.Close();
}
}
private void populateGridView()
{
openLogConnection();
try
{
command = new SqlCeCommand("SELECT * FROM joblog WHERE TimeStamp > @date", logConn);
command.Parameters.AddWithValue("@date", lastDeliveryDate);
dtLogSet = new DataTable();
bsLogSet = new BindingSource();
daLogSet = new SqlCeDataAdapter(command);
cbLogSet = new SqlCeCommandBuilder(daLogSet);
daLogSet.Fill(dtLogSet);
bsLogSet.DataSource = dtLogSet;
dataGridView1.DataSource = bsLogSet;
dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
logConn.Close();
}
}
누구나이 작업 권한을 얻는 방법을 알고 계십니까? 두 테이블의 타임 스탬프를 datetime 데이터 형식으로 저장하고 다음 형식으로 저장합니다. "MM/dd/yyyy hh : mm : ss tt"
'joblog' 테이블 정의를 게시 할 수 있습니까? – Xint0
SQLite 또는 SQL Serve Compact Edition을 실제로 사용하고 있습니까? – Xint0
SQL Server compact 4.0 –