Try to connect to access database through OleDbConnection (VB.net)
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.Oledb" %>
<script language="VB" runat="server">
Sub Page_Load()
Dim strConnection as String = "Provider=Microsoft.Jet.OLEDB.4.0;"
strConnection += "Data Source=C:\NonExistent.mdb"
data_src.text = strConnection
Dim objConnection as New OledbConnection(strConnection)
try
objConnection.Open()
con_open.text="Connection opened successfully.<br />"
objConnection.Close()
con_close.text="Connection closed.<br />"
catch e as Exception
con_open.text="Connection failed to open.<br />"
con_close.text=e.ToString()
end try
end Sub
</script>
<html>
<body>
<h4>Testing the data connection
<asp:label id="data_src" runat="server"/></h4>
<asp:label id="con_open" runat="server"/><br />
<asp:label id="con_close" runat="server"/><br />
</body>
</html>
Related examples in the same category