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里有查询语句的
{
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里有查询语句的
这里出错了,你看看你的sql语句有没有问题,数据库链接有没有问题
参数传了没
http://msdn.microsoft.com/zh-cn/library/ts49kyd2(v=VS.80).aspx
原来 string sql = string.Format("select * from NewsArticle where id='{0}'", id);
改成 string sql = "select * from NewsArticle where id=" + id + "";
就好了 为什么不能用上面那种写法? 还是谢谢大家了