public static DataRow GetDateRow(string sql)
        {
            DataSet ds = new DataSet();
            try
            {
                ConOpen();
                OleDbDataAdapter dpt = new OleDbDataAdapter(sql, conn);
                dpt.Fill(ds);
                int i = ds.Tables[0].Rows.Count;
                return i > 0 ? ds.Tables[0].Rows[0] : null;
            }
            catch
            {
                return null;
            }
            finally
            {
                ConClose();
            }        }单步调试的时候 直接跳过 
int i = ds.Tables[0].Rows.Count;  
return i > 0 ? ds.Tables[0].Rows[0] : null;
这两行 直接 到catch 里 然后 关闭数据库
sql里有查询语句的

解决方案 »

  1.   

    那说明fill的时候出问题了,检sql语句。连接字符串....乱七八糟的
      

  2.   

    dpt.Fill(ds);
    这里出错了,你看看你的sql语句有没有问题,数据库链接有没有问题
      

  3.   

    sql语句怎么写的
    参数传了没
    http://msdn.microsoft.com/zh-cn/library/ts49kyd2(v=VS.80).aspx
      

  4.   

    是sql语句的毛病 
    原来  string sql = string.Format("select * from NewsArticle where id='{0}'", id);
    改成  string sql = "select * from NewsArticle where id=" + id + "";
    就好了 为什么不能用上面那种写法? 还是谢谢大家了  
      

  5.   

    你把sql语句贴出来,大伙看看就知道什么问题了啥
      

  6.   

    id='{0}'因为你的id是数值类型...好好学SQL...
      

  7.   

    string sql = "select * from NewsArticle where id=" + id + ""string 类型的改string sql = "select * from NewsArticle where id='" + id + "'"
      

  8.   

    sql 把这个语句放到查询分析器里试试看
      

  9.   

    直接用DataTable填充即可 、