在asp.net里怎么调用access数据库中表的后几条内容显示到前台页面 ??
1个回答
展开全部
/// <summary>
/// 查询后5条数据
/// </summary>
/// <returns></returns>
public static DataSet alldydoc()
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select top 5 * ");
strSql.Append(" FROM dydoc ");
strSql.Append(" order by id desc");
return Query(strSql.ToString());
}
/// <summary>
/// 执行查询语句,返回DataSet
/// </summary>
/// <param name="SQLString">查询语句</param>
/// <returns>DataSet</returns>
public static DataSet Query(string SQLString)
{
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
DataSet ds = new DataSet();
try
{
connection.Open();
OleDbDataAdapter command = new OleDbDataAdapter(SQLString, connection);
command.Fill(ds, "ds");
}
catch (System.Data.OleDb.OleDbException ex)
{
throw new Exception(ex.Message);
}
return ds;
}
}
///连接语句
public static string connectionString = ""Provider=Microsoft.Jet.OLEDB.4.0;Data Source=数据库;
///页面调用用一个repeter就可以了,
/// 查询后5条数据
/// </summary>
/// <returns></returns>
public static DataSet alldydoc()
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select top 5 * ");
strSql.Append(" FROM dydoc ");
strSql.Append(" order by id desc");
return Query(strSql.ToString());
}
/// <summary>
/// 执行查询语句,返回DataSet
/// </summary>
/// <param name="SQLString">查询语句</param>
/// <returns>DataSet</returns>
public static DataSet Query(string SQLString)
{
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
DataSet ds = new DataSet();
try
{
connection.Open();
OleDbDataAdapter command = new OleDbDataAdapter(SQLString, connection);
command.Fill(ds, "ds");
}
catch (System.Data.OleDb.OleDbException ex)
{
throw new Exception(ex.Message);
}
return ds;
}
}
///连接语句
public static string connectionString = ""Provider=Microsoft.Jet.OLEDB.4.0;Data Source=数据库;
///页面调用用一个repeter就可以了,
TableDI
2024-07-18 广告
2024-07-18 广告
在上海悉息信息科技有限公司,我们深知Excel在数据处理中的重要作用。在Excel中引用不同工作表(sheet)的数据是常见的操作,这有助于整合和分析跨多个工作表的信息。通过在工作表名称前加上感叹号“!”,您可以轻松地引用其他工作表中的数据...
点击进入详情页
本回答由TableDI提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询