<%@ Import Namespace="SQLNameSpace" %>
<html>
<script language="VB" runat="server">
Dim Comp As SQLClass
Dim ConnStr      As String
Dim SQL          As String
Sub Page_Load(Source As Object, E As EventArgs) 
   Comp = New SQLClass()	
   Comp.ConnStr = "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=ASPNET;User ID=sa;"
    if NOT (isPostBack)
	rebind
    end if	
End Sub
Sub Show_Click(Sender As Object, E As EventArgs)
    Message.Text = "Masters 表已显示... "
    ReBind
End Sub
Sub Insert_click(Sender As Object, E As EventArgs)
    sql = "Insert into Masters(code_display,code_category,type)"
    sql = sql + "Values ('test',701,'E')"
    Comp.RunSql(sql)
    rebind
    Message.Text = "已插入记录...  " 
End Sub

Sub Delete_click(Sender As Object, E As EventArgs)
    sql = "delete from masters where code_display = 'test'"
    Comp.RunSql(sql)
    rebind
    Message.Text = "已删除记录..." 
End Sub

Sub Update_Click(Sender As Object, E As EventArgs)
    sql = "UPDATE Masters Set Opening = 90 WHERE code_display = 'test'"
    Comp.RunSQL(sql)
    rebind
	Message.Text = "已更新记录，将closing设为 90...! " 
End Sub

Sub ReBind()
    Comp.SQL = "select * from Masters"
    DataGrid1.DataSource=Comp.populate()
    DataGrid1.DataBind()
End Sub
    
    	
 </script>
	<body style="background-color='beige'; font-family='verdana'; font-size='10pt'">
		<h3>
			<font face="Verdana">VB中的数据库类</font>
		</h3>
		<form runat="server">
			<asp:button text="刷新" Onclick="Show_Click" 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:label id="Message" runat="server" />
			<asp:DataGrid id="DataGrid1" runat="server" />
		</form>
	</body>
</html>
