Start ⇒ All Programs ⇒ Visual Studio 2015
C:\ASP.NET-workspace\WebSite7\
.
C:\ASP.NET-workspace\WebSite7\WebSite7\Access\
Default.aspx
and Result.aspx
, as follows:
Default.aspx.vb
is given as follows:
Imports System Imports System.Data Imports System.Data.OleDb Imports System.Data.SqlClient Partial Class _Default Inherits System.Web.UI.Page Protected Sub Insert_Click( sender As Object, e As EventArgs ) Handles Insert.Click Dim conn As New OleDb.OleDbConnection( "Provider=Microsoft.ACE.OleDb.12.0;Data Source=" + Server.MapPath( "~/Access/Connect.accdb" ) ) Dim sql As String = "INSERT INTO Contacts( FullName, City ) VALUES( @FullName, @City )" Dim cmd As New OleDb.OleDbCommand( sql, conn ) cmd.Parameters.AddWithValue( "@FullName", FullName.Text ) cmd.Parameters.AddWithValue( "@City", City.Text ) conn.Open( ) cmd.ExecuteNonQuery( ) cmd.Dispose( ) conn.Close( ) Response.Redirect( "Result.aspx" ) End Sub End Class
Result.aspx.vb
is given as follows:
Partial Class Result Inherits System.Web.UI.Page Protected Sub Back_Click( sender As Object, e As EventArgs ) Handles Back.Click Response.Redirect( "Default.aspx" ) End Sub End Class
Build ⇒ Build Web SiteIf the build is successful, close the Access and debug the web site by selecting the options:
Debug ⇒ Start Without Debugging
Default.aspx | ⇒ Insert ⇐ Back |
Result.aspx |
File ⇒ Open ⇒ Project/Solution... ⇒ Open (C:\ASP.NET-workspace\WebSite7\WebSite7.sln)