数据库表里有7条记录,却只显示出来1条,程序错误在哪呢?求助
程序代码如下:
<%@page language= "C# " %>
<%@import namespace= "System.Data "%>
<%@import namespace= "System.Data.SqlClient "%>
<%@import namespace= "System.Data.OleDb "%>
<html>
<script language= "C# " runat=server>
void page_load(object serder,EventArgs e)
{
OleDbConnection oleconnection=new OleDbConnection( "provider=SQLOLEDB;database=chapter;user id=sa ");
OleDbCommand olecommand=new OleDbCommand();
OleDbDataReader oledatareader;
oleconnection.Open();
olecommand.Connection=oleconnection;
olecommand.CommandText= "select * from student ";
oledatareader=olecommand.ExecuteReader();
do
{
oledatareader.Read();
labcontext.Text+=oledatareader.GetString(0)+ " ";
labcontext.Text+=oledatareader.GetString(1)+ " ";
labcontext.Text+=oledatareader.GetInt32(2)+ " ";
labcontext.Text+=oledatareader.GetString(3)+ " "+ " <br> ";
}
while(oledatareader.NextResult());
olecommand=null;
oleconnection.Close();
oleconnection=null;
labcontext.Text+= "查找成功 ";
}
</script>
<body>
<form runat=server>
<asp:label id=labcontext runat=server /> <br>
</form>
</body>
</html>
已经在sql2000中建了一个名为chapter的数据库,里面有表student内容如下:
studentid name age address
97070701 kang 24 tianjin
97070702 li 21 shanghai
97070703 wang 20 beijing