<%@ Import Namespace=SystemData %>
<%@ Import NameSpace=SystemDataOleDb %>
<script laguage=VB runat=server>
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
sub page_load(sender as Objecte as EventArgs)
连接数据库
dim dbname as string
dbname=servermappath(authorsmdb)
myConnection = New OleDbConnection( PROVIDER=MicrosoftJetOLEDB;DATA Source=&dbname )
myConnectionOpen()
latext=Connection Opened!
添加记录
myCommand = New OleDbCommand( Insert INTO Authors(Authorscountry) Values(Simsonusa) myConnection )
myCommandExecuteNonQuery()
latext=New Record Inserted!
更新数据(Access)
myCommand = New OleDbCommand( UPDATE Authors SET Authors=Bennett WHERE Authors = Simson myConnection )
myCommandExecuteNonQuery()
latext=Record Updated!
删除数据(access)
myCommand = New OleDbCommand( DELETE FROM Authors WHERE Authors = David myConnection )
myCommandExecuteNonQuery()
latext=Record Deleted!
使用DateGrid显示数据
myCommand = New OleDbCommand( select * FROM Authors myConnection )
MyDataGridDataSource=myCommandExecutereader()
MyDataGridDataBind()
end sub
</script>
<html>
<body>
<asp:label id=la runat=server /><br>
<asp:label id=la runat=server /><br>
<asp:label id=la runat=server /><br>
<asp:label id=la runat=server /><br>
<ASP:DataGrid id=MyDataGrid runat=server
BorderColor=black
BorderWidth=
GridLines=Both
CellPadding=
CellSpacing=
FontName=Verdana
FontSize=pt
HeaderStyleBackColor=#aaaadd
AlternatingItemStyleBackColor=#eeeeee
>
</asp:DataGrid>
</body>
</html>