执行查询的疑惑
using System.Data.SqlClient;...
string abc = "SELECT TimeRecords.*,employee.emp_id FROM TimeRecords INNER JOIN employee ON TimeRecords.emp_id=employee.emp_id WHERE sign_time BETWEEN @Begin AND @End ";
SqlConnection cnn=new SqlConnection("server=PC-20110523OZLE;database=dz1;user id=sa;password=;min pool size=4;max pool size=4;");
cnn.Open();
SqlParameter[] Params=new SqlParameter[]{new SqlParameter("@Begin","2010-10-1"),new SqlParameter("@End","2010-10-20")};
SqlCommand cmd=new SqlCommand(abc,cnn);
cmd.Parameters.AddRange(Params);
SqlDataReader read = cmd.ExecuteReader();
MessageBox.Show();
上面的代码并没有返回数据(直接执行SQL语句能返回数据),查看,其中的@Begin和@End并没有被取代,不知为什么会这样.
@Begin和@End都是时间类型的数据.