<%@ Page Language="C#" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">
void Page_Load(object sender, EventArgs e) {
string ConnectionString = ConfigurationSettings.AppSettings["AccessConnectString"];
OleDbConnection myConnection = new OleDbConnection(ConnectionString);
try{
string CommandText = "UPDATE Publisher Set PublisherName='Old Publisher', PublisherCity = 'AAA' WHERE PublisherID = 6";
OleDbCommand myCommand = new OleDbCommand(CommandText, myConnection);
myConnection.Open();
lblRecords.Text = Convert.ToString(myCommand.ExecuteNonQuery());
} catch (Exception ex){
throw(ex);
} finally{
myConnection.Close();
}
}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
Records affected: <asp:Label id="lblRecords" runat="server"></asp:Label>
</form>
</body>
</html>
File: Web.config
<configuration>
<appSettings>
<add key="AccessConnectString" value="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Books.mdb;" />
</appSettings>
</configuration>
|