首页上一页 1 下一页尾页 1 条记录 1/1页
c#企业人事管理系统报出SQLExcepiton
发表在C#图书答疑
2010-08-01
是否精华
是
否
版块置顶:
是
否
老师:
我在运行你们的C#企业人事管理系统时报出了SQLExcepiton: 将 expression 转换为数据类型 datetime 时出现算术溢出错误。
public DataSet getDataSet(string SQLstr, string tableName)
{
getcon(); //打开与数据库的连接
SqlDataAdapter SQLda = new SqlDataAdapter(SQLstr, My_con); //创建一个SqlDataAdapter对象,并获取指定数据表的信息
DataSet My_DataSet = new DataSet(); //创建DataSet对象
[font color=#FF0000] SQLda.Fill(My_DataSet, tableName); [/font]//通过SqlDataAdapter对象的Fill()方法,将数据表信息添加到DataSet对象中
con_close(); //关闭数据库的连接
return My_DataSet; //返回DataSet对象的信息
//WritePrivateProfileString(string section, string key, string val, string filePath);
}
是在加红的SQLda.Fill(My_DataSet, tableName);这里报出这个异常的
另外经过我调试,我发现MyModule类的Pactory方法的时候报出的
public void PactDay(int i)
{
DataSet DSet = MyDataClass.getDataSet("select * from tb_Clew where kind=" + i + " and unlock=1", "tb_clew");
if (DSet.Tables[0].Rows.Count > 0)
{
string Vfield = "";
string dSQL = "";
int sday = Convert.ToInt32(DSet.Tables[0].Rows[0][1]);
if (i == 1)
{
Vfield = "Birthday";
dSQL = "select * from tb_Stuffbusic where (datediff(day,getdate(),convert(Nvarchar(12),cast (cast (year(getdate()) as char(4))+'-'+ cast(month(" + Vfield + ") as char(2))+'-'+ cast (day(" + Vfield + ") as char(2)) as datetime),110))<=" + sday + ") and (datediff(day,getdate(),convert(Nvarchar(12),cast (cast (year(getdate()) as char(4))+'-'+ cast(month(" + Vfield + ") as char(2))+'-'+cast (day(" + Vfield + ") as char(2)) as datetime),110))>=0)";
}
else
{
Vfield = "Pact_E";
[font color=#0000FF]dSQL = "select * from tb_Stuffbusic where ((getdate()-convert(Nvarchar(12)," + Vfield + ",110))>=-" + sday + " and (getdate()-convert(Nvarchar(12)," + Vfield + ",110))<=0)";
}
DSet = MyDataClass.getDataSet(dSQL, "tb_Stuffbusic");
[/font] if (DSet.Tables[0].Rows.Count > 0)
{
if (i == 1)
Vfield = "是否查看" + sday.ToString() + "天内过生日的职工信息?";
else
Vfield = "是否查看" + sday.ToString() + "天内合同到期的职工信息?";
if (MessageBox.Show(Vfield, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
{
DataClass.MyMeans.AllSql = dSQL;
Show_Form("人事档案浏览", 1);
}
}
}
}
是在执行完上面加颜色的语句后报出的这个SQLexception
请详细解答一下,谢谢
我在运行你们的C#企业人事管理系统时报出了SQLExcepiton: 将 expression 转换为数据类型 datetime 时出现算术溢出错误。
public DataSet getDataSet(string SQLstr, string tableName)
{
getcon(); //打开与数据库的连接
SqlDataAdapter SQLda = new SqlDataAdapter(SQLstr, My_con); //创建一个SqlDataAdapter对象,并获取指定数据表的信息
DataSet My_DataSet = new DataSet(); //创建DataSet对象
[font color=#FF0000] SQLda.Fill(My_DataSet, tableName); [/font]//通过SqlDataAdapter对象的Fill()方法,将数据表信息添加到DataSet对象中
con_close(); //关闭数据库的连接
return My_DataSet; //返回DataSet对象的信息
//WritePrivateProfileString(string section, string key, string val, string filePath);
}
是在加红的SQLda.Fill(My_DataSet, tableName);这里报出这个异常的
另外经过我调试,我发现MyModule类的Pactory方法的时候报出的
public void PactDay(int i)
{
DataSet DSet = MyDataClass.getDataSet("select * from tb_Clew where kind=" + i + " and unlock=1", "tb_clew");
if (DSet.Tables[0].Rows.Count > 0)
{
string Vfield = "";
string dSQL = "";
int sday = Convert.ToInt32(DSet.Tables[0].Rows[0][1]);
if (i == 1)
{
Vfield = "Birthday";
dSQL = "select * from tb_Stuffbusic where (datediff(day,getdate(),convert(Nvarchar(12),cast (cast (year(getdate()) as char(4))+'-'+ cast(month(" + Vfield + ") as char(2))+'-'+ cast (day(" + Vfield + ") as char(2)) as datetime),110))<=" + sday + ") and (datediff(day,getdate(),convert(Nvarchar(12),cast (cast (year(getdate()) as char(4))+'-'+ cast(month(" + Vfield + ") as char(2))+'-'+cast (day(" + Vfield + ") as char(2)) as datetime),110))>=0)";
}
else
{
Vfield = "Pact_E";
[font color=#0000FF]dSQL = "select * from tb_Stuffbusic where ((getdate()-convert(Nvarchar(12)," + Vfield + ",110))>=-" + sday + " and (getdate()-convert(Nvarchar(12)," + Vfield + ",110))<=0)";
}
DSet = MyDataClass.getDataSet(dSQL, "tb_Stuffbusic");
[/font] if (DSet.Tables[0].Rows.Count > 0)
{
if (i == 1)
Vfield = "是否查看" + sday.ToString() + "天内过生日的职工信息?";
else
Vfield = "是否查看" + sday.ToString() + "天内合同到期的职工信息?";
if (MessageBox.Show(Vfield, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
{
DataClass.MyMeans.AllSql = dSQL;
Show_Form("人事档案浏览", 1);
}
}
}
}
是在执行完上面加颜色的语句后报出的这个SQLexception
请详细解答一下,谢谢