private void Page_Load(object sender, System.EventArgs e)
{
Label1.Text="";
// {
SqlConnection mycn = null;
try
{
string myConnection = "server=local; uid =sa ;pwd =fjkdsla; database=TestSun";
string sql = "select * from books";
mycn = new SqlConnection(myConnection);
mycn.Open();
SqlCommand mysql = new SqlCommand(sql,mycn);
rep.DataSource = mysql.ExecuteReader();//////////////////////////rep 为Repeater的ID
rep.DataBind();
}
catch
{
Label1.Text="数据库连接出错,请检查!";
}
finally
{
if (mycn != null)
{
mycn.Close();
}
}
}
如上,用VS2003开发的一个留言,已经把数据读取出来绑定到Repeater里面,但还有一个问题,就是请问怎样写分页
{
Label1.Text="";
// {
SqlConnection mycn = null;
try
{
string myConnection = "server=local; uid =sa ;pwd =fjkdsla; database=TestSun";
string sql = "select * from books";
mycn = new SqlConnection(myConnection);
mycn.Open();
SqlCommand mysql = new SqlCommand(sql,mycn);
rep.DataSource = mysql.ExecuteReader();//////////////////////////rep 为Repeater的ID
rep.DataBind();
}
catch
{
Label1.Text="数据库连接出错,请检查!";
}
finally
{
if (mycn != null)
{
mycn.Close();
}
}
}
如上,用VS2003开发的一个留言,已经把数据读取出来绑定到Repeater里面,但还有一个问题,就是请问怎样写分页
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货