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 3 2394
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
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
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." This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 (??)
|
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
|
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
|
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,
|
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))
| |
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
|
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!
|
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
|
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.....
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |