HI all
New to C#
I'm merging datasets. The source dataset is an excel file and the target
dataset is in SqlServer.
salesTracingCommisionNDCdataset1.Merge(ndcExcel,fa lse,MissingSchemaAction.Error)
The merge works fine. It will populate a datagrid after the merge is
complete. However, when I issue the command to update the database, nothing
happens. No errors, no exceptions. nothing.
sqlDataAdapter2.Update(salesTracingCommisionNDCdat aset1);
I've checked the schemas, data typing, and I've ensured that the database
has a primary Key. I've also ensured that I have proper permissions on the
database
Also. I let the Wizard generate the Update Command code.
UPDATE SalesTracingCommissionNDCtable
SET ItemNumber = @ItemNumber, Qty = @Qty, InvoiceDate =
@InvoiceDate, BranchNo = @BranchNo
WHERE (BranchNo = @Original_BranchNo) AND (InvoiceDate =
@Original_InvoiceDate) AND (ItemNumber = @Original_ItemNumber) AND
(Qty = @Original_Qty OR
@Original_Qty IS NULL AND Qty IS NULL);
SELECT ItemNumber, Qty, InvoiceDate, BranchNo
FROM SalesTracingCommissionNDCtable
WHERE (BranchNo = @BranchNo) AND (InvoiceDate
= @InvoiceDate) AND (ItemNumber = @ItemNumber)
Any advice on debugging?? Any help is appreciated 6 4177
certolnut,
I think you should change the second parameter to true, to preserve the
changes in the dataset. I believe that when you pass false, it will cause
an AcceptChanges call to be made, which sets the state of all the rows to
Unchanged, which will not cause any updates to be made when passed through a
data adapter.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"certolnut" <ce*******@discussions.microsoft.com> wrote in message
news:14**********************************@microsof t.com... HI all
New to C#
I'm merging datasets. The source dataset is an excel file and the target dataset is in SqlServer.
salesTracingCommisionNDCdataset1.Merge(ndcExcel,fa lse,MissingSchemaAction.Error)
The merge works fine. It will populate a datagrid after the merge is complete. However, when I issue the command to update the database, nothing happens. No errors, no exceptions. nothing.
sqlDataAdapter2.Update(salesTracingCommisionNDCdat aset1);
I've checked the schemas, data typing, and I've ensured that the database has a primary Key. I've also ensured that I have proper permissions on the database
Also. I let the Wizard generate the Update Command code.
UPDATE SalesTracingCommissionNDCtable SET ItemNumber = @ItemNumber, Qty = @Qty, InvoiceDate = @InvoiceDate, BranchNo = @BranchNo WHERE (BranchNo = @Original_BranchNo) AND (InvoiceDate = @Original_InvoiceDate) AND (ItemNumber = @Original_ItemNumber) AND (Qty = @Original_Qty OR @Original_Qty IS NULL AND Qty IS NULL); SELECT ItemNumber, Qty, InvoiceDate, BranchNo FROM SalesTracingCommissionNDCtable WHERE (BranchNo = @BranchNo) AND (InvoiceDate = @InvoiceDate) AND (ItemNumber = @ItemNumber)
Any advice on debugging?? Any help is appreciated
Hi Nicholas, Thanks for the reply.
I gave it a shot, no luck.
Thanks for the advice though, I'll make sure and have this set to "true" in
the future..
I'll keep trying.. It's just seems weird that it wouldn't throw some kind of
exception...
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Oy**************@tk2msftngp13.phx.gbl... certolnut,
I think you should change the second parameter to true, to preserve
the changes in the dataset. I believe that when you pass false, it will cause an AcceptChanges call to be made, which sets the state of all the rows to Unchanged, which will not cause any updates to be made when passed through
a data adapter.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"certolnut" <ce*******@discussions.microsoft.com> wrote in message news:14**********************************@microsof t.com... HI all
New to C#
I'm merging datasets. The source dataset is an excel file and the target dataset is in SqlServer.
salesTracingCommisionNDCdataset1.Merge(ndcExcel,fa lse,MissingSchemaAction.Er
ror)
The merge works fine. It will populate a datagrid after the merge is complete. However, when I issue the command to update the database, nothing happens. No errors, no exceptions. nothing.
sqlDataAdapter2.Update(salesTracingCommisionNDCdat aset1);
I've checked the schemas, data typing, and I've ensured that the
database has a primary Key. I've also ensured that I have proper permissions on
the database
Also. I let the Wizard generate the Update Command code.
UPDATE SalesTracingCommissionNDCtable SET ItemNumber = @ItemNumber, Qty = @Qty, InvoiceDate = @InvoiceDate, BranchNo = @BranchNo WHERE (BranchNo = @Original_BranchNo) AND (InvoiceDate = @Original_InvoiceDate) AND (ItemNumber = @Original_ItemNumber) AND (Qty = @Original_Qty OR @Original_Qty IS NULL AND Qty IS NULL); SELECT ItemNumber, Qty, InvoiceDate,
BranchNo FROM SalesTracingCommissionNDCtable WHERE (BranchNo = @BranchNo) AND (InvoiceDate = @InvoiceDate) AND (ItemNumber = @ItemNumber)
Any advice on debugging?? Any help is appreciated
Neal,
Are you trying to update in the event handler for a UI component? If
so, then try and wrap the code in a try/catch block. Exceptions that are
thrown in these event handlers are swallowed by the framework.
Also, check to make sure that the rows don't have a state of "unchanged"
associated with them.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Neal Whitney" <wh**********@hotmail.com> wrote in message
news:eR**************@TK2MSFTNGP14.phx.gbl... Hi Nicholas, Thanks for the reply.
I gave it a shot, no luck.
Thanks for the advice though, I'll make sure and have this set to "true" in the future..
I'll keep trying.. It's just seems weird that it wouldn't throw some kind of exception...
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:Oy**************@tk2msftngp13.phx.gbl... certolnut,
I think you should change the second parameter to true, to preserve the changes in the dataset. I believe that when you pass false, it will cause an AcceptChanges call to be made, which sets the state of all the rows to Unchanged, which will not cause any updates to be made when passed through a data adapter.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"certolnut" <ce*******@discussions.microsoft.com> wrote in message news:14**********************************@microsof t.com... > HI all > > New to C# > > I'm merging datasets. The source dataset is an excel file and the > target > dataset is in SqlServer. > > salesTracingCommisionNDCdataset1.Merge(ndcExcel,fa lse,MissingSchemaAction.Er ror) > > > The merge works fine. It will populate a datagrid after the merge is > complete. However, when I issue the command to update the database, > nothing > happens. No errors, no exceptions. nothing. > > sqlDataAdapter2.Update(salesTracingCommisionNDCdat aset1); > > I've checked the schemas, data typing, and I've ensured that the database > has a primary Key. I've also ensured that I have proper permissions on the > database > > Also. I let the Wizard generate the Update Command code. > > UPDATE SalesTracingCommissionNDCtable > SET ItemNumber = @ItemNumber, Qty = @Qty, InvoiceDate = > @InvoiceDate, BranchNo = @BranchNo > WHERE (BranchNo = @Original_BranchNo) AND (InvoiceDate = > @Original_InvoiceDate) AND (ItemNumber = @Original_ItemNumber) AND > (Qty = @Original_Qty OR > @Original_Qty IS NULL AND Qty IS NULL); > SELECT ItemNumber, Qty, InvoiceDate, BranchNo > FROM SalesTracingCommissionNDCtable > WHERE (BranchNo = @BranchNo) AND > (InvoiceDate > = @InvoiceDate) AND (ItemNumber = @ItemNumber) > > Any advice on debugging?? Any help is appreciated
Ok, Well, I wasn't trying to update a UI component by I went ahead and
wrapped the code anyway (always a good idea), but still no luck.
try
{
salesTracingCommisionNDCdataset1.Merge(ndcExcel,tr ue,MissingSchemaAction.Err
or);
sqlDataAdapter2.Update(salesTracingCommisionNDCdat aset1);
}
catch
{
Console.WriteLine("error");
// Error during Update, add code to locate error, reconcile
// and try to update again.
}
I tried looking for the Row property that you were talking about, but I
couldn't find it in the debugger..
I found a rowDiffId property (set to undefined) and a tablerowchanged
property (also set to undefined). the count has changed from 0 to 252
(correct number of new rows). But still nothing..
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:On**************@TK2MSFTNGP10.phx.gbl... Neal,
Are you trying to update in the event handler for a UI component? If so, then try and wrap the code in a try/catch block. Exceptions that are thrown in these event handlers are swallowed by the framework.
Also, check to make sure that the rows don't have a state of
"unchanged" associated with them.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Neal Whitney" <wh**********@hotmail.com> wrote in message news:eR**************@TK2MSFTNGP14.phx.gbl... Hi Nicholas, Thanks for the reply.
I gave it a shot, no luck.
Thanks for the advice though, I'll make sure and have this set to "true" in the future..
I'll keep trying.. It's just seems weird that it wouldn't throw some
kind of exception...
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:Oy**************@tk2msftngp13.phx.gbl... certolnut,
I think you should change the second parameter to true, to preserve the changes in the dataset. I believe that when you pass false, it will cause an AcceptChanges call to be made, which sets the state of all the rows
to Unchanged, which will not cause any updates to be made when passed through a data adapter.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"certolnut" <ce*******@discussions.microsoft.com> wrote in message news:14**********************************@microsof t.com... > HI all > > New to C# > > I'm merging datasets. The source dataset is an excel file and the > target > dataset is in SqlServer. > >
salesTracingCommisionNDCdataset1.Merge(ndcExcel,fa lse,MissingSchemaAction.Er ror) > > > The merge works fine. It will populate a datagrid after the merge is > complete. However, when I issue the command to update the database, > nothing > happens. No errors, no exceptions. nothing. > > sqlDataAdapter2.Update(salesTracingCommisionNDCdat aset1); > > I've checked the schemas, data typing, and I've ensured that the database > has a primary Key. I've also ensured that I have proper permissions
on the > database > > Also. I let the Wizard generate the Update Command code. > > UPDATE SalesTracingCommissionNDCtable > SET ItemNumber = @ItemNumber, Qty = @Qty, InvoiceDate = > @InvoiceDate, BranchNo = @BranchNo > WHERE (BranchNo = @Original_BranchNo) AND (InvoiceDate = > @Original_InvoiceDate) AND (ItemNumber = @Original_ItemNumber) AND > (Qty = @Original_Qty OR > @Original_Qty IS NULL AND Qty IS NULL); > SELECT ItemNumber, Qty, InvoiceDate, BranchNo > FROM SalesTracingCommissionNDCtable > WHERE (BranchNo = @BranchNo) AND > (InvoiceDate > = @InvoiceDate) AND (ItemNumber = @ItemNumber) > > Any advice on debugging?? Any help is appreciated
Neal,
You want to check the RowState property on the DataRow (if you are
looking at a DataRowView, then use the Row property to expose the row). If
that value is DataRowState.Unchanged, then it will not be processed by a
data adapter.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"certolnut" <wh**********@hotmail.com> wrote in message
news:ub**************@TK2MSFTNGP12.phx.gbl... Ok, Well, I wasn't trying to update a UI component by I went ahead and wrapped the code anyway (always a good idea), but still no luck.
try {
salesTracingCommisionNDCdataset1.Merge(ndcExcel,tr ue,MissingSchemaAction.Err or); sqlDataAdapter2.Update(salesTracingCommisionNDCdat aset1); } catch {
Console.WriteLine("error"); // Error during Update, add code to locate error, reconcile // and try to update again. }
I tried looking for the Row property that you were talking about, but I couldn't find it in the debugger..
I found a rowDiffId property (set to undefined) and a tablerowchanged property (also set to undefined). the count has changed from 0 to 252 (correct number of new rows). But still nothing.. "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:On**************@TK2MSFTNGP10.phx.gbl... Neal,
Are you trying to update in the event handler for a UI component? If so, then try and wrap the code in a try/catch block. Exceptions that are thrown in these event handlers are swallowed by the framework.
Also, check to make sure that the rows don't have a state of "unchanged" associated with them.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Neal Whitney" <wh**********@hotmail.com> wrote in message news:eR**************@TK2MSFTNGP14.phx.gbl... > Hi Nicholas, Thanks for the reply. > > I gave it a shot, no luck. > > Thanks for the advice though, I'll make sure and have this set to > "true" > in > the future.. > > I'll keep trying.. It's just seems weird that it wouldn't throw some kind > of > exception... > > "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> > wrote > in > message news:Oy**************@tk2msftngp13.phx.gbl... >> certolnut, >> >> I think you should change the second parameter to true, to >> preserve > the >> changes in the dataset. I believe that when you pass false, it will >> cause >> an AcceptChanges call to be made, which sets the state of all the rows to >> Unchanged, which will not cause any updates to be made when passed >> through > a >> data adapter. >> >> Hope this helps. >> >> >> -- >> - Nicholas Paldino [.NET/C# MVP] >> - mv*@spam.guard.caspershouse.com >> >> "certolnut" <ce*******@discussions.microsoft.com> wrote in message >> news:14**********************************@microsof t.com... >> > HI all >> > >> > New to C# >> > >> > I'm merging datasets. The source dataset is an excel file and the >> > target >> > dataset is in SqlServer. >> > >> > > salesTracingCommisionNDCdataset1.Merge(ndcExcel,fa lse,MissingSchemaAction.Er > ror) >> > >> > >> > The merge works fine. It will populate a datagrid after the merge is >> > complete. However, when I issue the command to update the database, >> > nothing >> > happens. No errors, no exceptions. nothing. >> > >> > sqlDataAdapter2.Update(salesTracingCommisionNDCdat aset1); >> > >> > I've checked the schemas, data typing, and I've ensured that the > database >> > has a primary Key. I've also ensured that I have proper permissions on > the >> > database >> > >> > Also. I let the Wizard generate the Update Command code. >> > >> > UPDATE SalesTracingCommissionNDCtable >> > SET ItemNumber = @ItemNumber, Qty = @Qty, InvoiceDate = >> > @InvoiceDate, BranchNo = @BranchNo >> > WHERE (BranchNo = @Original_BranchNo) AND (InvoiceDate = >> > @Original_InvoiceDate) AND (ItemNumber = @Original_ItemNumber) AND >> > (Qty = @Original_Qty OR >> > @Original_Qty IS NULL AND Qty IS NULL); >> > SELECT ItemNumber, Qty, InvoiceDate, > BranchNo >> > FROM >> > SalesTracingCommissionNDCtable >> > WHERE (BranchNo = @BranchNo) AND >> > (InvoiceDate >> > = @InvoiceDate) AND (ItemNumber = @ItemNumber) >> > >> > Any advice on debugging?? Any help is appreciated >> >> > >
Hi Nicholas
Thanks so much again for your help.
After much wrangling, I found out that the RowState was indeed unchanged.
Now my only question is, how do I get this value moved to "changed"???
Clearly the rows have changed since the target dataset was completely empty
before, and now it has 11 rows which I can reference.
I must be missing a step here....
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Oc**************@TK2MSFTNGP14.phx.gbl... Neal,
You want to check the RowState property on the DataRow (if you are looking at a DataRowView, then use the Row property to expose the row).
If that value is DataRowState.Unchanged, then it will not be processed by a data adapter.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"certolnut" <wh**********@hotmail.com> wrote in message news:ub**************@TK2MSFTNGP12.phx.gbl... Ok, Well, I wasn't trying to update a UI component by I went ahead and wrapped the code anyway (always a good idea), but still no luck.
try {
salesTracingCommisionNDCdataset1.Merge(ndcExcel,tr ue,MissingSchemaAction.Err or); sqlDataAdapter2.Update(salesTracingCommisionNDCdat aset1); } catch {
Console.WriteLine("error"); // Error during Update, add code to locate error, reconcile // and try to update again. }
I tried looking for the Row property that you were talking about, but I couldn't find it in the debugger..
I found a rowDiffId property (set to undefined) and a tablerowchanged property (also set to undefined). the count has changed from 0 to 252 (correct number of new rows). But still nothing.. "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:On**************@TK2MSFTNGP10.phx.gbl... Neal,
Are you trying to update in the event handler for a UI component?
If so, then try and wrap the code in a try/catch block. Exceptions that
are thrown in these event handlers are swallowed by the framework.
Also, check to make sure that the rows don't have a state of "unchanged" associated with them.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Neal Whitney" <wh**********@hotmail.com> wrote in message news:eR**************@TK2MSFTNGP14.phx.gbl... > Hi Nicholas, Thanks for the reply. > > I gave it a shot, no luck. > > Thanks for the advice though, I'll make sure and have this set to > "true" > in > the future.. > > I'll keep trying.. It's just seems weird that it wouldn't throw some kind > of > exception... > > "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> > wrote > in > message news:Oy**************@tk2msftngp13.phx.gbl... >> certolnut, >> >> I think you should change the second parameter to true, to >> preserve > the >> changes in the dataset. I believe that when you pass false, it will >> cause >> an AcceptChanges call to be made, which sets the state of all the
rows to >> Unchanged, which will not cause any updates to be made when passed >> through > a >> data adapter. >> >> Hope this helps. >> >> >> -- >> - Nicholas Paldino [.NET/C# MVP] >> - mv*@spam.guard.caspershouse.com >> >> "certolnut" <ce*******@discussions.microsoft.com> wrote in message >> news:14**********************************@microsof t.com... >> > HI all >> > >> > New to C# >> > >> > I'm merging datasets. The source dataset is an excel file and the >> > target >> > dataset is in SqlServer. >> > >> > >
salesTracingCommisionNDCdataset1.Merge(ndcExcel,fa lse,MissingSchemaAction.Er > ror) >> > >> > >> > The merge works fine. It will populate a datagrid after the merge
is >> > complete. However, when I issue the command to update the
database, >> > nothing >> > happens. No errors, no exceptions. nothing. >> > >> > sqlDataAdapter2.Update(salesTracingCommisionNDCdat aset1); >> > >> > I've checked the schemas, data typing, and I've ensured that the > database >> > has a primary Key. I've also ensured that I have proper
permissions on > the >> > database >> > >> > Also. I let the Wizard generate the Update Command code. >> > >> > UPDATE SalesTracingCommissionNDCtable >> > SET ItemNumber = @ItemNumber, Qty = @Qty, InvoiceDate
= >> > @InvoiceDate, BranchNo = @BranchNo >> > WHERE (BranchNo = @Original_BranchNo) AND (InvoiceDate = >> > @Original_InvoiceDate) AND (ItemNumber = @Original_ItemNumber) AND >> > (Qty = @Original_Qty OR >> > @Original_Qty IS NULL AND Qty IS NULL); >> > SELECT ItemNumber, Qty, InvoiceDate, > BranchNo >> > FROM >> > SalesTracingCommissionNDCtable >> > WHERE (BranchNo = @BranchNo) AND >> > (InvoiceDate >> > = @InvoiceDate) AND (ItemNumber = @ItemNumber) >> > >> > Any advice on debugging?? Any help is appreciated >> >> > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Programatix |
last post by:
Hi,
I'm working on a WebService project. I'm trying to validate data before they
are updated to the database by handling the RowUpdating event for a
SqlDataAdapter.
The data being handled has...
|
by: Steven Blair |
last post by:
Hi,
Here is a short decsription of my problem.
I have written a dll for Database accessing. I have one method which can
return a Dataset and another method which takes a Dataset and upates a...
|
by: Christoph |
last post by:
I'm delving into using ADO.NET for the first time. In fact, I've never
done any database work using C# at all so all of this is new to me.
Please bear that in mind if I am asking stupid questions....
|
by: Fernando |
last post by:
I am having problems with updating the changes done over a DataSet to a
Database.
All the changes being done using the Form are stored in the Dataset, but
when i decide to close the Form and open...
|
by: LP |
last post by:
Hello,
In the past I used SqlCommandBuilder and SqlDataAdapter .Update method to
apply changes in a DataTable back to its table source in SQL Server. It
worked fine when DataSet had only 1...
| |
by: archana |
last post by:
hi all
I have some doubts related to database handling in .net.
I am using sqldataadapter to update and insert rows into database.
What i want to know is at a time of inserting rows using...
|
by: languy |
last post by:
Hi there
I'm having a problem when using the SqlDataAdapter. When calling the
Update(DataSet, string) method I get the following error message "String or
binary data would be truncated". The...
|
by: Aaron |
last post by:
Hello,
The SqlDataAdapter has 4 properties of type SqlCommand, SelectCommand,
UpdateCommand, DeleteCommand, and InsertCommand. Setting the
SelectCommand allows the SqlDataAdapter to retrieve...
|
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: 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...
|
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: 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...
|
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.
| |