<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Debug="true" %>
<%@ import Namespace="System.Data "%>
<%@ import Namespace="System.Data.SqlClient" %>
<head runat="server">
<title>无标题页</title>
</head>
<script language="c#" runat="server" >
void page_load(object serder,EventArgs e)
{
SqlConnection sqlcon=new SqlConnection("Data Source=127.0.0.1;uid=sa;pwd=;Initial Catalog=chapter");
DataSet ds=new DataSet();
sqlcon.Open();
SqlDataAdapter sqld=new SqlDataAdapter("select * from student",sqlcon);
SqlCommandBuilder objcmdbld=new SqlCommandBuilder(sqld);
sqld.Fill(ds,"tabstudent");
DataRow drow;
drow=ds.Tables["tabstudent"].NewRow ();
drow[0]="97070705";
drow[1]="huang";
drow[2]=30;
drow[3]="bejing";
ds.Tables["tabstudent"].Rows.Add(drow);
ds.Tables["tabstudent"].AcceptChanges();
sqld.Update(ds, "tabstudent");
dg.DataSource=ds.Tables["tabstudent"].DefaultView;
dg.DataBind();
sqlcon.Close();
sqlcon=null;
labContent.Text+="查找成功";
}
</script>
<body>
<form id="form1" runat="server">
<asp:DataGrid ID="dg" runat="server" /><br />
<asp:Label ID="labContent" runat="server" /><br />
</form>
</body>
</html>
我只是执行输入一条记录,,没有显示记录的语句,为什么显示结果时,还有把所有记录都显示出来了呢,
[此贴子已经被作者于2007-4-20 14:58:45编辑过]