我有这个 c# 代码,其中有一个我想在 datagridview 中显示的查询:
string select = "SELECT E.employeeNumber AS 'Employee Number',
E.employeePrivateName +' '+E.employeeFamilyName AS 'Employee_Name',
DATEDIFF (MONTH,E.startWorkingDate, GETDATE()) AS 'Seniority in
Month'
FROM TblEmployee E " ;
Connection c = new Connection();
SqlDataAdapter dataAdapter = new SqlDataAdapter(select, c.con); //c.con is the connection string
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);
DataSet ds = new DataSet();
dataAdapter.Fill(ds);
dataGridView1.ReadOnly = true;
dataGridView1.DataSource = ds.Tables[0];
问题在于datediff
,因为我在 datagridview 中呈现的查询结果是空的。
谢谢。