<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<html>
<head>
<title>OleDbCommand Example</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<script language="C#" runat="server">
string html;
protected void Page_Load ( Object src, EventArgs e ) {
// specify the data source
OleDbConnection myConn = new OleDbConnection (
"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" +
Server.MapPath ( "~/app_data/pubs.mdb" ) );
// define the command query
string query = "SELECT * FROM Authors";
// initialize command object with the specified query and connection
OleDbCommand myCmd = new OleDbCommand ( query, myConn );
// open the data connection
myConn.Open ( );
// retrieve properties of the command object
html += "<table cellspacing=1 class=data width=90%>";
html += "<tr><td><b>CommandText</b></td>";
html += "<td>" + myCmd.CommandText + "</td></tr>";
html += "<tr><td><b>CommandTimeout</b></td>";
html += "<td>" + myCmd.CommandTimeout + "</td></tr>";
html += "<tr><td><b>CommandType</b></td>";
html += "<td>" + myCmd.CommandType + "</td></tr>";
html += "<tr><td><b>Connection</b></td>";
html += "<td>" + myCmd.Connection + "</td></tr>";
html += "<tr><td><b>Parameters</b></td>";
html += "<td>" + myCmd.Parameters + "</td></tr>";
html += "<tr><td><b>Transaction</b></td>";
html += "<td>" + myCmd.Transaction + "</td></tr>";
html += "<tr><td><b>UpdatedRowSource</b></td>";
html += "<td>" + myCmd.UpdatedRowSource + "</td></tr>";
html += "</table>";
// close the data connection
myConn.Close ( );
}
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc" -->
<div class="header"><h2>ADO.NET Primer: <b>OleDbCommand</b> Example</h2></div>
<hr size=1 width=92%>
<center>
<p><i>Properties of current <b>OleDbCommand</b> object</i></p>
<%= html %>
</center>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>