J
Jim in Arizona
I'm doing my best to learn ASPNET from a book devoted to ASPNET 1.0. So far,
I haven't run into any problems, until now.
This is a simple page that should just show the sql strings created by the
CommandBuilder (or is it data adapter) object.
Here is my code (the books code, actually):
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim strConnection, strSQL As String
Dim objDataSet As New DataSet()
Dim objConnection As OleDbConnection
Dim objAdapter As OleDbDataAdapter
Dim objBuilder As OleDbCommandBuilder
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\hhsinternal\comlog\testing.mdb"
strSQL = "SELECT FirstName, LastName from tmaster;"
objConnection = New OleDbConnection(strConnection)
objAdapter = New OleDbDataAdapter(strSQL, objConnection)
objBuilder = New OleDbCommandBuilder(objAdapter)
objAdapter.UpdateCommand = objBuilder.GetUpdateCommand()
objAdapter.InsertCommand = objBuilder.GetInsertCommand()
objAdapter.DeleteCommand = objBuilder.GetDeleteCommand()
lblselectcmd.Text = objAdapter.SelectCommand.CommandText
lblupdatecmd.Text = objAdapter.UpdateCommand.CommandText
lblinsertcmd.Text = objAdapter.InsertCommand.CommandText
lbldeletecmd.Text = objAdapter.DeleteCommand.CommandText
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title></head><body>
<form id="form1" runat="server">
<div>
<table border=1>
<tr>
<th>Command</th>
<th>CommandText</th>
</tr>
<tr>
<td>Select Command</td>
<td><asp:Label id="lblselectcmd" runat=server /></td>
</tr>
<tr>
<td>Update Command</td>
<td><asp:Label id="lblupdatecmd" runat=server /></td>
</tr>
<tr>
<td>Insert Command</td>
<td><asp:Label id="lblinsertcmd" runat=server /></td>
</tr>
<tr>
<td>Delete Command</td>
<td><asp:Label id="lbldeletecmd" runat=server /></td>
</tr>
</table>
</div>
</form>
</body>
</html>
I don't really know what this error means or what I should do about it.
Dynamic SQL generation for the UpdateCommand is not supported against a
SelectCommand that does not return any key column information.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Dynamic SQL generation
for the UpdateCommand is not supported against a SelectCommand that does not
return any key column information.
Source Error:
The source code that generated this unhandled exception can only be
shown when compiled in debug mode. To enable this, please follow one of the
below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated
the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your
application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given
application to be compiled in debug mode. The first technique will cause
only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a
memory/performance overhead. You should make sure that an application has
debugging disabled before deploying into production scenario.
Stack Trace:
[InvalidOperationException: Dynamic SQL generation for the UpdateCommand is
not supported against a SelectCommand that does not return any key column
information.]
System.Data.Common.CommandBuilder.BuildUpdateCommand(DataTableMapping
mappings, DataRow dataRow) +3049
System.Data.OleDb.OleDbCommandBuilder.GetUpdateCommand() +35
ASP.datasets3_aspx.Page_Load(Object sender, EventArgs e) +111
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
I haven't run into any problems, until now.
This is a simple page that should just show the sql strings created by the
CommandBuilder (or is it data adapter) object.
Here is my code (the books code, actually):
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim strConnection, strSQL As String
Dim objDataSet As New DataSet()
Dim objConnection As OleDbConnection
Dim objAdapter As OleDbDataAdapter
Dim objBuilder As OleDbCommandBuilder
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\hhsinternal\comlog\testing.mdb"
strSQL = "SELECT FirstName, LastName from tmaster;"
objConnection = New OleDbConnection(strConnection)
objAdapter = New OleDbDataAdapter(strSQL, objConnection)
objBuilder = New OleDbCommandBuilder(objAdapter)
objAdapter.UpdateCommand = objBuilder.GetUpdateCommand()
objAdapter.InsertCommand = objBuilder.GetInsertCommand()
objAdapter.DeleteCommand = objBuilder.GetDeleteCommand()
lblselectcmd.Text = objAdapter.SelectCommand.CommandText
lblupdatecmd.Text = objAdapter.UpdateCommand.CommandText
lblinsertcmd.Text = objAdapter.InsertCommand.CommandText
lbldeletecmd.Text = objAdapter.DeleteCommand.CommandText
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title></head><body>
<form id="form1" runat="server">
<div>
<table border=1>
<tr>
<th>Command</th>
<th>CommandText</th>
</tr>
<tr>
<td>Select Command</td>
<td><asp:Label id="lblselectcmd" runat=server /></td>
</tr>
<tr>
<td>Update Command</td>
<td><asp:Label id="lblupdatecmd" runat=server /></td>
</tr>
<tr>
<td>Insert Command</td>
<td><asp:Label id="lblinsertcmd" runat=server /></td>
</tr>
<tr>
<td>Delete Command</td>
<td><asp:Label id="lbldeletecmd" runat=server /></td>
</tr>
</table>
</div>
</form>
</body>
</html>
I don't really know what this error means or what I should do about it.
Dynamic SQL generation for the UpdateCommand is not supported against a
SelectCommand that does not return any key column information.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Dynamic SQL generation
for the UpdateCommand is not supported against a SelectCommand that does not
return any key column information.
Source Error:
The source code that generated this unhandled exception can only be
shown when compiled in debug mode. To enable this, please follow one of the
below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated
the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your
application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given
application to be compiled in debug mode. The first technique will cause
only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a
memory/performance overhead. You should make sure that an application has
debugging disabled before deploying into production scenario.
Stack Trace:
[InvalidOperationException: Dynamic SQL generation for the UpdateCommand is
not supported against a SelectCommand that does not return any key column
information.]
System.Data.Common.CommandBuilder.BuildUpdateCommand(DataTableMapping
mappings, DataRow dataRow) +3049
System.Data.OleDb.OleDbCommandBuilder.GetUpdateCommand() +35
ASP.datasets3_aspx.Page_Load(Object sender, EventArgs e) +111
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750