473,387 Members | 1,863 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,387 software developers and data experts.

.net table adapter code behind missing UPDATE statement

in a new project using .net 2005, c#.

getting err message "Update requires a valid UpdateCommand when passed
DataRow collection with modified rows."

source RDBMS is oracle 8i. I add a new dataset to the project and drag
a datatable from server explorer onto the dataset design surface. In
the configuration wizard, under advanced options the "refresh data
table" is disabled ie I am not able to check it (note if the source db
is sql server this option is enabled).

I click next and accept defaults. The Insert and Select commands are
created, but not the Update command (note if the source db is sql
server the update command is created). The Insert, Select, and Update
methods are all created, just not the update command.

I am trying to use typed datasets to pass into the DAL for updates, so
I'm not sure that I need to use command builder as a workaround as it
appears cb will take a generic dataset only (unless an overload for
each typed dataset is written).

I also suppose a workaround could be to type the update command
manually but we have over 100 tables ...

I tried copying the SQL Server update command into the code behind of
the oracle equivalent but it didn't take (I receive the same error msg
as when there is no update statement).

the connection types I've tried are ODBC, OLEDB, Oracle Database etc
all seem to give the same result.

please let me know if there is a way to have the adapter automatically
create the update statement from an oracle 8i db.

Sep 18 '06 #1
2 11122

Hi - I had the same issue with Oracle in VS 2003.

Check to make sure that the TABLE you are working with has a PRIMARY KEY
CONSTRAINT. It can't be a INDEX that enforces uniqueness on the table. It has
to be a PRIMARY KEY CONSTRAINT.

This issue with VS 2003 was that the UpdateCommand builder wizard (or
whatever you call it) would bail on creating the UpdateCommand if it could
not find a primary key on the table. In order words it could not build a SQL
statement that could update just ONE RECORD (i.e. so the dataset -
dataadapter could always find the right record to update).

In SQL Server the UpdateCommand builder is a little more forgiving - with
Oracle it's not.

Now I'm not sure if this is the case with VS 2005 (which is what you are
using) but I got a feeling it might be. It's worth a shot anyway.

Once you get beyond this you are going to like working with .NET and Oracle
8i. It works pretty darn well... and I have several production systems out
there working within this context.

ANOTHER CRITICAL TIP! Make sure your Oracle field names are less than 20
characters or the command builder is going to give you troubles. If you want
more information on this - feel free to ping me directly...

Good luck!

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
"tr******@gmail.com" wrote:
in a new project using .net 2005, c#.

getting err message "Update requires a valid UpdateCommand when passed
DataRow collection with modified rows."

source RDBMS is oracle 8i. I add a new dataset to the project and drag
a datatable from server explorer onto the dataset design surface. In
the configuration wizard, under advanced options the "refresh data
table" is disabled ie I am not able to check it (note if the source db
is sql server this option is enabled).

I click next and accept defaults. The Insert and Select commands are
created, but not the Update command (note if the source db is sql
server the update command is created). The Insert, Select, and Update
methods are all created, just not the update command.

I am trying to use typed datasets to pass into the DAL for updates, so
I'm not sure that I need to use command builder as a workaround as it
appears cb will take a generic dataset only (unless an overload for
each typed dataset is written).

I also suppose a workaround could be to type the update command
manually but we have over 100 tables ...

I tried copying the SQL Server update command into the code behind of
the oracle equivalent but it didn't take (I receive the same error msg
as when there is no update statement).

the connection types I've tried are ODBC, OLEDB, Oracle Database etc
all seem to give the same result.

please let me know if there is a way to have the adapter automatically
create the update statement from an oracle 8i db.

Sep 20 '06 #2
Thanks, I think that might do the trick...

we are converting a legacy system and I know for a fact that the
original db didn't use primary keys. I thought the unique indexes might
have worked but I will try adding an explicit PK.

thanks again
Franklin M. Gauer III wrote:
Hi - I had the same issue with Oracle in VS 2003.

Check to make sure that the TABLE you are working with has a PRIMARY KEY
CONSTRAINT. It can't be a INDEX that enforces uniqueness on the table. It has
to be a PRIMARY KEY CONSTRAINT.

This issue with VS 2003 was that the UpdateCommand builder wizard (or
whatever you call it) would bail on creating the UpdateCommand if it could
not find a primary key on the table. In order words it could not build a SQL
statement that could update just ONE RECORD (i.e. so the dataset -
dataadapter could always find the right record to update).

In SQL Server the UpdateCommand builder is a little more forgiving - with
Oracle it's not.

Now I'm not sure if this is the case with VS 2005 (which is what you are
using) but I got a feeling it might be. It's worth a shot anyway.

Once you get beyond this you are going to like working with .NET and Oracle
8i. It works pretty darn well... and I have several production systems out
there working within this context.

ANOTHER CRITICAL TIP! Make sure your Oracle field names are less than 20
characters or the command builder is going to give you troubles. If you want
more information on this - feel free to ping me directly...

Good luck!

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
"tr******@gmail.com" wrote:
in a new project using .net 2005, c#.

getting err message "Update requires a valid UpdateCommand when passed
DataRow collection with modified rows."

source RDBMS is oracle 8i. I add a new dataset to the project and drag
a datatable from server explorer onto the dataset design surface. In
the configuration wizard, under advanced options the "refresh data
table" is disabled ie I am not able to check it (note if the source db
is sql server this option is enabled).

I click next and accept defaults. The Insert and Select commands are
created, but not the Update command (note if the source db is sql
server the update command is created). The Insert, Select, and Update
methods are all created, just not the update command.

I am trying to use typed datasets to pass into the DAL for updates, so
I'm not sure that I need to use command builder as a workaround as it
appears cb will take a generic dataset only (unless an overload for
each typed dataset is written).

I also suppose a workaround could be to type the update command
manually but we have over 100 tables ...

I tried copying the SQL Server update command into the code behind of
the oracle equivalent but it didn't take (I receive the same error msg
as when there is no update statement).

the connection types I've tried are ODBC, OLEDB, Oracle Database etc
all seem to give the same result.

please let me know if there is a way to have the adapter automatically
create the update statement from an oracle 8i db.
Sep 20 '06 #3

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

Similar topics

6
by: Mark Kurten | last post by:
for some reason when i delete a row, the row doesn't get deleted from the acutal data table in SQL server. my code follows what am i missing? thanks. Dim row As DataRow Try
10
by: Trevor | last post by:
Hey, I am trying to do this tutorial on the microsoft site : http://msdn.microsoft.com/library/default.asp? url=/library/en-us/dndotnet/html/usingadonet.asp I can get everything to work up to...
11
by: Eych | last post by:
I get a VB error when I try to update a table whose field I change with the following statement: dcUpdate.Dataset.Tables(0).Rows(0)("User Name") = Me.textbox1.Text if I change the field name...
8
by: Marcel Hug | last post by:
Hi all ! I have datas in a dataset. I would like to save them in a new table (just created). Do I have to run trought all recordsets with an Insert into statement ? (it takes very long) Thanks
1
by: cindy | last post by:
this is the call private void Page_Load(object sender, System.EventArgs e) { OdbcConnection connection = new OdbcConnection ("DSN=PFW52"); CreateDataAdapter(connection); } this is the code,...
7
by: Serge Rielau | last post by:
Hi all, Following Ian's passionate postings on problems with ALTOBJ and the alter table wizard in the control center I'll try to explain how to use ALTOBJ with this thread. I'm not going to get...
1
by: David | last post by:
I have a SQLExpress database with a table that has a unique index. I am creating dataset/Table Adapter using the wizard. THe Wizard creates a select and insert commands, but does not create a...
12
by: Randy | last post by:
Hi, Trying to pass along a table row delete to the datasource, but I'm crashing. Here is the code: Private Sub btnDeleteIngr_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles...
3
by: planethax | last post by:
I have multiple arrays that I need to insert/update database and I am not sure how to start, I think I need to use the "foreach" statement and also not sure whether or not to serialize and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.