Can anyone tell me what's wrong with strConnection in the following
example?
<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.OleDb" %>
<script Language="c#" runat="server">
void Page_Load(object sender, System.EventArgs e) {
// This doesn't work, except when I remove the password
from the database and the connection string:
String strConnection = "Provider=Microsoft.Jet.OLEDB.4.0; data source=" +
Server.MapPath("db\\test.mdb")+ ";password=MyPassword";
con_string.Text = strConnection + "<br/>";
OleDbConnection conn = new OleDbConnection(strConnection);
try {
conn.Open();
con_open.Text="Opened<br/>";
conn.Close();
con_close.Text="closed<br/>";
}
catch (Exception ex) {
con_open.Text="failed<br/>";
}
}
</script>
<html>
<body>
<asp:label id="con_open" runat="server"/><br />
<asp:label id="con_close" runat="server"/><br />
<asp:label id="con_string" runat="server"/><br />
</body>
</html>