<%@ Import Namespace="SQLNameSpaceC" %>
<html>
<script language="C#" runat="server">
SQLClassC comp = new SQLClassC();
public void Page_Load(Object sender, EventArgs E)
{

comp.SQL = "Select * From Masters";
comp.ConnStr = "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=ASPNET;User ID=sa;";
bind();
string sql = "Insert into Masters(code_display,code_category,type)";
sql = sql + "Values ('test',701,'E')";
comp.RunSQL(sql);
}
public void Insert_Click(Object sender, EventArgs E)
{
string sql = "Insert into Masters(code_display,code_category,type)";
sql = sql + "Values ('test',701,'E')";
comp.RunSQL(sql);
bind();		    
}
  
public void Update_Click(Object sender, EventArgs E)
{
string sql =   "UPDATE Masters Set Opening = 90 WHERE code_display = 'test'";
comp.RunSQL(sql);
bind();		    
} 
  
public void Delete_Click(Object sender, EventArgs E)
{
string sql = "delete from masters where code_display = 'test'";
comp.RunSQL(sql);
bind();		    
}

public void bind()
{
DataGrid1.DataSource=comp.Populate();
DataGrid1.DataBind();
}
</script>

<body>
<h3><font face="Verdana">C#中的SQL 类  </font></h3>
<form  runat=server>
<asp:button text="插入" onclick ="Insert_Click" runat=server/>
<asp:button text="更新" Onclick="Update_Click" runat=server/>
<asp:button text="删除" Onclick="Delete_Click" runat=server/>
<asp:DataGrid id="DataGrid1" runat="server" /> 
</font>
</form>
</body>
</html>

