<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.OleDb" %>
<script laguage="VB" runat="server">
Dimmen Sie myConnection als OleDbConnection
Dimmen Sie myCommand als OleDbCommand
sub page_load(sender as Object,e as EventArgs)
'1.连接数据库
dim dbname als string
dbname=server.mappath("authors.mdb")
myConnection = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="&dbname )
myConnection.Open()
la1.text="Verbindung geöffnet!"
'2.添加记录
myCommand = New OleDbCommand( "Insert INTO Authors(Authors,country) Values('Simson','usa')", myConnection )
myCommand.ExecuteNonQuery()
la2.text="Neuer Datensatz eingefügt!"
'3 更新数据(Zugriff)
myCommand = New OleDbCommand( "UPDATE Authors SET Authors='Bennett' WHERE Authors = 'Simson'", myConnection )
myCommand.ExecuteNonQuery()
la3.text="Datensatz aktualisiert!"
'4 删除数据(Zugriff)
myCommand = New OleDbCommand( "DELETE FROM Authors WHERE Authors = 'David'", myConnection )
myCommand.ExecuteNonQuery()
la4.text="Datensatz gelöscht!"
'5 Tage DateGrid-Konto
myCommand = New OleDbCommand( "select * FROM Authors", myConnection )
MyDataGrid.DataSource=myCommand.Executereader()
MyDataGrid.DataBind()
Ende sub
</script>
<html>
<Körper>
<asp:label id="la1" runat="server" /><br>
<asp:label id="la2" runat="server" /><br>
<asp:label id="la3" runat="server" /><br>
<asp:label id="la4" runat="server" /><br>
<ASP:DataGrid id="MyDataGrid" runat="server"
BorderColor="schwarz"
BorderWidth="1"
GridLines="Beide"
CellPadding="3"
CellSpacing="0"
Font-Name="Verdana"
Schriftgröße="10pt"
HeaderStyle-BackColor="#aaaadd"
AlternatingItemStyle-BackColor="#eeeeee"
>
</asp:DataGrid>
</body>
</html>