Hi,
I have a table in the database. I have a method which will
return a table with the same structure as the DB one and
with all data I need.
What I want to do is to remove all data in the DB table
and reload it with the table I created.
I tried to use SqlDBAdaptor and it seems I cannot do
something like
ds.Tables[0]=myTable
It does not work.
So what would be the best way for me to achieve it in
ADO.NET?
Thanks a lot
Chris 6 1807
Hi Chris,
Try using DataTable.Copy method instead.
--
Miha Markic - RightHand .NET consulting & development
miha at rthand com www.rthand.com
"chris" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl... Hi,
I have a table in the database. I have a method which will return a table with the same structure as the DB one and with all data I need. What I want to do is to remove all data in the DB table and reload it with the table I created. I tried to use SqlDBAdaptor and it seems I cannot do something like ds.Tables[0]=myTable It does not work. So what would be the best way for me to achieve it in ADO.NET? Thanks a lot
Chris
Thanks Miha. Copy works, but I still have not find the
right way to update my DB in one shot. Here is my codes.
The purpose is to load the table from the DB, delete all,
then load what I have and reload it to the DB. Did I miss
something?
Thanks for the help
//dt is the poluated table I used
SqlConnection sconn = new SqlConnection(connectString);
SqlDataAdapter da = new SqlDataAdapter(
"select * from [mytable]",connectString);
DataSet ds = new DataSet();
da.Fill(ds);
DataTable dbTable=ds.Tables[0];
dbTable.Clear();
dbTable=dt.Copy();
dbTable.AcceptChanges();
da.Update(ds); -----Original Message----- Hi Chris,
Try using DataTable.Copy method instead.
-- Miha Markic - RightHand .NET consulting & development miha at rthand com www.rthand.com
"chris" <an*******@discussions.microsoft.com> wrote in
messagenews:09****************************@phx.gbl... Hi,
I have a table in the database. I have a method which
will return a table with the same structure as the DB one and with all data I need. What I want to do is to remove all data in the DB table and reload it with the table I created. I tried to use SqlDBAdaptor and it seems I cannot do something like ds.Tables[0]=myTable It does not work. So what would be the best way for me to achieve it in ADO.NET? Thanks a lot
Chris
.
Hi Chris,
Calling AcceptChanges before Update is classical error :)
You should invert the order.
However, you don't neet do copy rows to dataset's table.
Just call da.Update(dt); instead.
--
Miha Markic - RightHand .NET consulting & development
miha at rthand com www.rthand.com
"Chris" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl... Thanks Miha. Copy works, but I still have not find the right way to update my DB in one shot. Here is my codes. The purpose is to load the table from the DB, delete all, then load what I have and reload it to the DB. Did I miss something? Thanks for the help
//dt is the poluated table I used
SqlConnection sconn = new SqlConnection(connectString); SqlDataAdapter da = new SqlDataAdapter( "select * from [mytable]",connectString); DataSet ds = new DataSet(); da.Fill(ds);
DataTable dbTable=ds.Tables[0]; dbTable.Clear(); dbTable=dt.Copy(); dbTable.AcceptChanges(); da.Update(ds);
-----Original Message----- Hi Chris,
Try using DataTable.Copy method instead.
-- Miha Markic - RightHand .NET consulting & development miha at rthand com www.rthand.com
"chris" <an*******@discussions.microsoft.com> wrote in messagenews:09****************************@phx.gbl... Hi,
I have a table in the database. I have a method which will return a table with the same structure as the DB one and with all data I need. What I want to do is to remove all data in the DB table and reload it with the table I created. I tried to use SqlDBAdaptor and it seems I cannot do something like ds.Tables[0]=myTable It does not work. So what would be the best way for me to achieve it in ADO.NET? Thanks a lot
Chris
.
Hi Miha,
Following your direction, after correcting a bunch of
other mistakes, I finally get my things work as what I
want.
Thank you very much for your help.
Chris -----Original Message----- Hi Chris,
Calling AcceptChanges before Update is classical error :) You should invert the order. However, you don't neet do copy rows to dataset's table. Just call da.Update(dt); instead.
-- Miha Markic - RightHand .NET consulting & development miha at rthand com www.rthand.com
"Chris" <an*******@discussions.microsoft.com> wrote in
messagenews:01****************************@phx.gbl... Thanks Miha. Copy works, but I still have not find the right way to update my DB in one shot. Here is my codes. The purpose is to load the table from the DB, delete
all, then load what I have and reload it to the DB. Did I
miss something? Thanks for the help
//dt is the poluated table I used
SqlConnection sconn = new SqlConnection(connectString); SqlDataAdapter da = new SqlDataAdapter( "select * from [mytable]",connectString); DataSet ds = new DataSet(); da.Fill(ds);
DataTable dbTable=ds.Tables[0]; dbTable.Clear(); dbTable=dt.Copy(); dbTable.AcceptChanges(); da.Update(ds);
>-----Original Message----- >Hi Chris, > >Try using DataTable.Copy method instead. > >-- >Miha Markic - RightHand .NET consulting & development >miha at rthand com >www.rthand.com > >"chris" <an*******@discussions.microsoft.com> wrote in message >news:09****************************@phx.gbl... >> Hi, >> >> I have a table in the database. I have a method which will >> return a table with the same structure as the DB one
and >> with all data I need. >> What I want to do is to remove all data in the DB
table >> and reload it with the table I created. >> I tried to use SqlDBAdaptor and it seems I cannot do >> something like >> ds.Tables[0]=myTable >> It does not work. >> So what would be the best way for me to achieve it in >> ADO.NET? >> Thanks a lot >> >> Chris > > >. >
.
When do you think it is a good idea to call AcceptChanges and RejectChanges
at all? For a simple scenario like Chris's example how about just leaving
out the AcceptChanges call altogether?
Brad Williams
"Miha Markic" <miha at rthand com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl... Hi Chris,
Calling AcceptChanges before Update is classical error :) You should invert the order. However, you don't neet do copy rows to dataset's table. Just call da.Update(dt); instead.
-- Miha Markic - RightHand .NET consulting & development miha at rthand com www.rthand.com
"Chris" <an*******@discussions.microsoft.com> wrote in message news:01****************************@phx.gbl... Thanks Miha. Copy works, but I still have not find the right way to update my DB in one shot. Here is my codes. The purpose is to load the table from the DB, delete all, then load what I have and reload it to the DB. Did I miss something? Thanks for the help
//dt is the poluated table I used
SqlConnection sconn = new SqlConnection(connectString); SqlDataAdapter da = new SqlDataAdapter( "select * from [mytable]",connectString); DataSet ds = new DataSet(); da.Fill(ds);
DataTable dbTable=ds.Tables[0]; dbTable.Clear(); dbTable=dt.Copy(); dbTable.AcceptChanges(); da.Update(ds);
-----Original Message----- Hi Chris,
Try using DataTable.Copy method instead.
-- Miha Markic - RightHand .NET consulting & development miha at rthand com www.rthand.com
"chris" <an*******@discussions.microsoft.com> wrote in messagenews:09****************************@phx.gbl... > Hi, > > I have a table in the database. I have a method which will> return a table with the same structure as the DB one and > with all data I need. > What I want to do is to remove all data in the DB table > and reload it with the table I created. > I tried to use SqlDBAdaptor and it seems I cannot do > something like > ds.Tables[0]=myTable > It does not work. > So what would be the best way for me to achieve it in > ADO.NET? > Thanks a lot > > Chris
.
Hi Brad,
Thanks for the suggestions. So at what senario should I
use acceptchanges and what senario shouldn't I use it?
What are pros and cons for using/(not using it)?
Thanks
Chris -----Original Message----- When do you think it is a good idea to call AcceptChanges
and RejectChangesat all? For a simple scenario like Chris's example how
about just leavingout the AcceptChanges call altogether?
Brad Williams
"Miha Markic" <miha at rthand com> wrote in message news:%2***************@TK2MSFTNGP10.phx.gbl... Hi Chris,
Calling AcceptChanges before Update is classical
error :) You should invert the order. However, you don't neet do copy rows to dataset's table. Just call da.Update(dt); instead.
-- Miha Markic - RightHand .NET consulting & development miha at rthand com www.rthand.com
"Chris" <an*******@discussions.microsoft.com> wrote in
message news:01****************************@phx.gbl... > Thanks Miha. Copy works, but I still have not find the > right way to update my DB in one shot. Here is my
codes. > The purpose is to load the table from the DB, delete
all, > then load what I have and reload it to the DB. Did I
miss > something? > Thanks for the help > > //dt is the poluated table I used > > SqlConnection sconn = new SqlConnection
(connectString); > SqlDataAdapter da = new SqlDataAdapter( > "select * from [mytable]",connectString); > DataSet ds = new DataSet(); > da.Fill(ds); > > DataTable dbTable=ds.Tables[0]; > dbTable.Clear(); > dbTable=dt.Copy(); > dbTable.AcceptChanges(); > da.Update(ds); > > >-----Original Message----- > >Hi Chris, > > > >Try using DataTable.Copy method instead. > > > >-- > >Miha Markic - RightHand .NET consulting & development > >miha at rthand com > >www.rthand.com > > > >"chris" <an*******@discussions.microsoft.com> wrote
in > message > >news:09****************************@phx.gbl... > >> Hi, > >> > >> I have a table in the database. I have a method
which > will > >> return a table with the same structure as the DB
one and > >> with all data I need. > >> What I want to do is to remove all data in the DB
table > >> and reload it with the table I created. > >> I tried to use SqlDBAdaptor and it seems I cannot
do > >> something like > >> ds.Tables[0]=myTable > >> It does not work. > >> So what would be the best way for me to achieve it
in > >> ADO.NET? > >> Thanks a lot > >> > >> Chris > > > > > >. > >
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sarah Tanembaum |
last post by:
Beside its an opensource and supported by community, what's the fundamental
differences between PostgreSQL and those high-price commercial database (and
some are bloated such as Oracle) from...
|
by: Sandman |
last post by:
Just looking for suggestion on how to do this in my Web application.
The goal is to keep track of what a user has and hasn't read and present him or
her with new material
I am currently doing...
|
by: Uthuras |
last post by:
Greetings,
Machine : Pentium IV
Os Windows 2000 server
Product : DB2 UDB Release : 7.2
We are fail to load the following data file format into db2 database
table that has long varchar...
|
by: Prince Kumar |
last post by:
When running LOAD with "ALLOW READ ACCESS", I get the following error
if select is running againt the table (isolation UR).
load.sql
---------
db2 load from /u02/data/dly_d040817_test.dat of...
|
by: Max |
last post by:
This is the best method I've found to store and load settings from database.
I load the settings once at start as public variables. The method can be
called easily anytime you want to load the new...
| |
by: Ethan V |
last post by:
I have a few options regarding populating the state combo box
1. On page load, get the 50 states from the database
2. On application start, get the 50 states from the database and cache them
in...
|
by: JAKDND |
last post by:
I'm trying to find out the best architecture would be for a web+access
solution. We have a database of individuals' job details. There's a big
table with an ID key field, name addess etc, and a...
|
by: James Conrad StJohn Foreman |
last post by:
After 3 years of using DB2 on Linux, I'm leaving my current employers
to go work for a SQL Server shop instead. In order to find my
replacement, they're trying to put together a set of questions...
|
by: trullock |
last post by:
Hi,
Can anyone suggest the best way to go about the following...
I'm tracking clicks (mouse down x,y coordinates) on a web page by
using some javascript to create an XHR which sends the...
|
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,...
|
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,...
| |
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...
|
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,...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
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...
| |