473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

UpdateCommand error

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.BuildUpdateComma nd(DataTableMapping
mappings, DataRow dataRow) +3049
System.Data.OleDb.OleDbCommandBuilder.GetUpdateCom mand() +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

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET
Version:1.1.4322.2032

Nov 19 '05 #1
3 2650
Sorry, forgot to add debug=true so I could get the real error.
So, here's my code, again, and the error is below that.
Thanks.

<%@ 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>

Server Error in '/' Application.
--------------------------------------------------------------------------------

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:

Line 23:
Line 24: objBuilder = New OleDbCommandBuilder(objAdapter)
Line 25: objAdapter.UpdateCommand = objBuilder.GetUpdateCommand()
Line 26: objAdapter.InsertCommand = objBuilder.GetInsertCommand()
Line 27: objAdapter.DeleteCommand = objBuilder.GetDeleteCommand()

Source File: E:\hhsinternal\comlog\datasets3.aspx Line: 25

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.BuildUpdateComma nd(DataTableMapping
mappings, DataRow dataRow) +3049
System.Data.OleDb.OleDbCommandBuilder.GetUpdateCom mand() +35
ASP.datasets3_aspx.Page_Load(Object sender, EventArgs e) in
E:\hhsinternal\comlog\datasets3.aspx:25
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET
Version:1.1.4322.2032
Nov 19 '05 #2
Looks like your table does not have a primary key defined.

"Jim in Arizona" <ti*******@hotmail.com> wrote in message
news:O2**************@TK2MSFTNGP12.phx.gbl...
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.BuildUpdateComma nd(DataTableMapping
mappings, DataRow dataRow) +3049
System.Data.OleDb.OleDbCommandBuilder.GetUpdateCom mand() +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

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.4322.2032;
ASP.NET Version:1.1.4322.2032

Nov 19 '05 #3

"Marina" <so*****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Looks like your table does not have a primary key defined.


I can't believe it.
My tables (the only two in that DB) each have a PK, but I didn't select the
PK field in my sql statement:
SELECT firstname, lastname from tmaster

So, I changed it to
SELECT * from tmaster

and now it works.

I didn't think it matterd what I had in my select statement as long as I
wasn't later trying to display or use data that didn't exist in the select
statement.

Thanks,
Jim
Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dzemo | last post by:
i use this code to get data into dataset cmd.CommandType = CommandType.Text cmdUpdate.CommandType = CommandType.Text cmdUpdate.CommandText = "Update BigOne Set Rezultat=? where ID=?" ...
9
by: whaletyr | last post by:
When I try to update an access database using the commandbuilder and updatecommand. I get the An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll ...
5
by: Peter W Johnson | last post by:
Hi Guys, I am having problems getting the following code to update an Access table. I get the following error:- An unhandled exception of type 'System.NullReferenceException' occurred in...
2
by: susan.f.barrett | last post by:
Hi, Despite me being able to type the following in to SQL Server and it updating 1 row: > updatestockcategory 1093, 839 In my code, it is not updating any rows. dataSet = new DataSet();
5
by: wandii | last post by:
Hi, I am trying to update the customer table by using the updatecommd, please see below, however, when it runs it does not fire the update statement. I ran the sql profiler and the only...
1
by: Rich | last post by:
Hello, I can update a dataset from my client app using a dataAdapter.Updatecommand when I add parameter values outside of the param declaration. But If I add the param values inline with the...
6
by: Rich | last post by:
Dim da As New SqlDataAdapter("Select * from tbl1", conn) dim tblx As New DataTable da.Fill(tblx) '--works OK up to this point da.UpdateCommand = New SqlCommand da.UpdateCommand.Connection =...
0
by: stuart_dent | last post by:
I have a SQL Server table with in Indetity column (value auto generated). I have tried to write my own updatecommand code. I can't get it to work. An error says that says Sku and rid are...
0
by: Giovanni | last post by:
Hi, I'm new in vs2k8 and I'm trying to build up an ASP application that uses a DB. Situation: 2 tables related by a key (pk->fk). A Gridview on a web page that show me the 2 tables join query's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.