注册 登录
编程论坛 ASP.NET技术论坛

关键字变色时遇到datatime类型!

tatawlb 发布于 2008-07-03 10:15, 1172 次点击
提示错误:
该字符串未被识别为有效的 DateTime。不能在 news_PosTime 列中存储 <<font color=red >2008</font>-1-2 16:17:47>。所需类型是 DateTime。
代码是:(DB类中的调用代码!)
 OleDbConnection ole = DB.CreateDb();
        ole.Open();
        OleDbCommand olecm = new OleDbCommand(olecmd,ole);
        OleDbDataAdapter odr = new OleDbDataAdapter();
        DataSet ds = new DataSet();
        odr.SelectCommand = olecm;
        odr.Fill(ds);
        if (bs != "")
        {
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
                {
                    ds.Tables[0].Rows[i][j] = Convert.ToString(ds.Tables[0].Rows[i][j]).Replace(bs, "<font color=red >" + bs.ToString() + "</font>");
                }
            }            
        }
        return ds;


怎么才能在for循环中不换datatime类型的字段!!
3 回复
#2
雪雨星风2008-07-03 10:32
你把它换成varchar
#3
hebingbing2008-07-03 11:02
貌似关键代码不是这段啊……
#4
tatawlb2008-07-03 11:03
回复 2# 雪雨星风 的帖子
已经解决了!  
  谢谢!
1