<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="NameSpaceHersh" %>

<html>
<script language="VB" runat="server">
Dim SQL as string, vcn as string
Sub Page_Load(Source As Object, E As EventArgs) 
	vcn= "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 Table Displayed... "
	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')"
	RunSQL(sql)
	rebind
	Message.Text =   " ..Inserted test record...  " 
End Sub
Sub Delete_click(Sender As Object, E As EventArgs)
	sql = "delete from masters where code_display = 'test'"
	RunSQL(sql)
	rebind
	Message.Text = "...Deleted all test records..." 
End Sub
Sub Update_Click(Sender As Object, E As EventArgs)
	sql = "UPDATE Masters Set Opening = 90 WHERE code_display = 'test'"
	RunSQL(sql) 
	rebind
	Message.Text =  "...Updated all test records: Set closing balance = 90...! " 
End Sub
Sub ReBind()
	Dim t As NameSpaceHersh.SqlService = New NameSpaceHersh.SqlService()
	Dim vsql as string
	Dim ds as DataSet
	vSQL = "select * from Masters"
	ds = t.Populate(vcn, vSql)
	DataGrid1.DataSource=ds.Tables("vTable").DefaultView
	DataGrid1.DataBind()
End Sub
Function RunSQL (vSQL as String)
	Dim t As NameSpaceHersh.SqlService = New NameSpaceHersh.SqlService()
	t.RunSQL(vcn,vSQL)
END Function
</script>
<body>
<body style="font: 10pt verdana; background-color:beige">
<form  runat=server>
 <h4> ASP .NET Web Services </h4>
 <asp:button text="Refresh" Onclick="Show_Click" runat=server/>
 <asp:button text="Insert" Onclick="Insert_Click" runat=server/>
 <asp:button text="Update" Onclick="Update_Click" runat=server/>
 <asp:button text="Delete" Onclick="delete_Click" runat=server/>
 <asp:label id="Message"  runat=server/>
 <asp:DataGrid id="DataGrid1" runat="server" /> 
</form>
</body>
</html>
