<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<html>
<script language="VB" runat="server">
Dim myConnection As OleDbConnection
Dim SQL     as String
Dim ConnStr as String

Sub Page_Load(Source As Object, E As EventArgs) 
   ConnStr = "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=ASPNET;User ID=sa;"
   myConnection = New OleDbConnection(ConnStr)      
   try
	Dim mycommand As New OleDbCommand(sql,myConnection)
	myConnection.Open()
	Response.Write("打开连接 " + MyConnection.ConnectionString + "<br>")
	
   catch myException as Exception
	Response.Write("出现异常: " + myException.ToString()) 
   finally
        'Close the connection explicitly
        Response.Write("关闭连接。注意显示地关闭连接是非常重要的。")
        myConnection.Close()
   end try
	    
End Sub
</script>

</html>

