473,695 Members | 2,357 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using dataadpater.Upd ate(datatable) when the da is from a file

I want to update records from a csv file.

I do this in a button click:

//Create Adapters
da = new OdbcDataAdapter ("Select * FROM test.csv", conn);

//Fill a data table
da.Fill(dt);

//Populate grid with file data
dataGrid1.DataS ource = dt;

//Builder
csvBuilder = new OdbcCommandBuil der(da);

// Close the connection
conn.Close();

In another button click I delete some rows:

I loop thru the datarow and call dr.Delete() on the appropiate row and then
call dataGrid1.Refre sh() which updates the grid with the remaining rows.

In another button click I want to update the test.csv file I pulled the data
from by doing this:

da.Update(dt);

But it throws this exception:

Additional information: Dynamic SQL generation for the DeleteCommand is not
supported against a SelectCommand that does not return any key column
information.

Does this mean my file needs to have a primary key. It does not, so how do I
update the file.

Thanks


Nov 16 '05 #1
3 2397
Yes, you're going to need a key in order to run an Update w/ CommandBUilder-
regardless of the source.

--
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
<Pa******@newsg roup.nospam> wrote in message
news:E4******** *************** ***********@mic rosoft.com...
I want to update records from a csv file.

I do this in a button click:

//Create Adapters
da = new OdbcDataAdapter ("Select * FROM test.csv", conn);

//Fill a data table
da.Fill(dt);

//Populate grid with file data
dataGrid1.DataS ource = dt;

//Builder
csvBuilder = new OdbcCommandBuil der(da);

// Close the connection
conn.Close();

In another button click I delete some rows:

I loop thru the datarow and call dr.Delete() on the appropiate row and then call dataGrid1.Refre sh() which updates the grid with the remaining rows.

In another button click I want to update the test.csv file I pulled the data from by doing this:

da.Update(dt);

But it throws this exception:

Additional information: Dynamic SQL generation for the DeleteCommand is not supported against a SelectCommand that does not return any key column
information.

Does this mean my file needs to have a primary key. It does not, so how do I update the file.

Thanks


Nov 16 '05 #2
Is there any other way for me to update the csv file without having a key?

or is there a way for me to add a key to the csv file, and then use the
da.update(dt). The key can't be a unique key.

Paul

"W.G. Ryan eMVP" wrote:
Yes, you're going to need a key in order to run an Update w/ CommandBUilder-
regardless of the source.

--
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
<Pa******@newsg roup.nospam> wrote in message
news:E4******** *************** ***********@mic rosoft.com...
I want to update records from a csv file.

I do this in a button click:

//Create Adapters
da = new OdbcDataAdapter ("Select * FROM test.csv", conn);

//Fill a data table
da.Fill(dt);

//Populate grid with file data
dataGrid1.DataS ource = dt;

//Builder
csvBuilder = new OdbcCommandBuil der(da);

// Close the connection
conn.Close();

In another button click I delete some rows:

I loop thru the datarow and call dr.Delete() on the appropiate row and

then
call dataGrid1.Refre sh() which updates the grid with the remaining rows.

In another button click I want to update the test.csv file I pulled the

data
from by doing this:

da.Update(dt);

But it throws this exception:

Additional information: Dynamic SQL generation for the DeleteCommand is

not
supported against a SelectCommand that does not return any key column
information.

Does this mean my file needs to have a primary key. It does not, so how do

I
update the file.

Thanks



Nov 16 '05 #3
Hi Paul,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to update a csv file. If there
is any misunderstandin g, please feel free to let me know.

Generally, when we need to update a database, we need a primary key column
to let the command builder generate update commands for you.

However, as far as I know, the Text driver for accessing .csv files is
readonly. It doesn't support updating, which means whether we have a
primary key or not, we cannot update the data source.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #4

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

Similar topics

6
2126
by: rob | last post by:
Hey, I need to update a row in one table with a row (most but not all columns) from another table. This sounds like there should be a really easy way to do this. I've seen there's FROM in the UPDATE statement but haven't found any similar examples. Basically, I need something like this pseudo-code: update table2 set something = table1.something (??)
1
1554
by: Primerov | last post by:
Why i cannot update from another form? I have an update function called UpdateData that works otherwise,but not from another form. Why is it so? I am trying to update tables from the form F1.There i have the following code : DoCmd.OpenForm " F2" UpdateData
2
1195
by: Thomas | last post by:
I have a Informix Database on Solaris and a SQL database. I need to update from Informix to SQL daily. Is there any easy way of doing it? BTW, I tried to use OleDbDataAdpater.Update to do the job. Nothing happened after the program worked diligently for a while. Thanks
9
2344
by: mike_li | last post by:
We are considering to update from V8.1 Fixpak 8 to Fixpak 9. Operating System Information: OSName: AIX NodeName: mdxxx01, mdxxx02, mdxxx03, mdxxx04 Version: 5 Release: 2 64 bits and DB2 code release SQL08021 with level identifier 03020106 Informational tokens are DB2 v8.1.1.80, special_13100, U800400_13100,
1
19784
by: Lars E | last post by:
Hi all I have a small problem. I have a datatable with 8 columns. But it is only data in 5 of the columns. Data for the remaing 3 columns is in another dataset. I Want to run trough the datatable and fill out the remaining data. My code so far: if (this.fetch("custinfo", "fetchCustInfo", out customers, parameters))
8
2522
by: Richard | last post by:
Hello! I have this piece of SQL code: UPDATE a SET Field1 = c.Field1 FROM a INNER JOIN b ON a.GUID1 = b.GUID1 INNER JOIN c ON b.GUID2 = c.GUID2 WHERE c.Type = 1
0
1059
by: bbqbbq | last post by:
Hi All, I need find a way to dynamicly fill a DetailsView using DataTable. Can you give me a sample? Thanks a lot!
1
4598
by: vinodkus | last post by:
dear sir/madam Can any one help me how to connect ASP and MS ACCESS using FILE DSN. Thanks in Advance vinod
1
2523
by: jaredciagar | last post by:
Hi guys...can you help me please.... I'm using ASP.net, MSSQL 2005 and VB Script I have don't know how to bind data in gridview control from database. I want also to allow paging in gridview so I want to bind data using datatable or dataset... Can you write the code for me in VB script? Thank You in advance.....
0
8647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8585
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9132
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9004
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8864
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8838
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6506
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
2288
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.