Everytime I edit a record, and hit update I get duplicating lines in my Details View. Here's my If statement: - If (Len(e.OldValues("AutoNumber")) > 0) Then
-
sql = "UPDATE SHIP_LOG SET FileNumber='" & e.NewValues("FileNumber") & "',BOL='" & e.NewValues("BOL") & "',Container='" & e.NewValues("Container") & "',DESTN='" & e.NewValues("DESTN") & "', Comments='" & e.NewValues("Comments") & "' WHERE POD_COMINV='" & e.Keys("POD_COMINV") & "' AND LineIndex='" & e.Keys("LineIndex") & "'"
-
Else
-
sql = "INSERT INTO SHIP_LOG (POD_COMINV,FileNumber,BOL,Container,DESTN,Comments,LineIndex) VALUES ('" & e.Keys("POD_COMINV") & "','" & e.NewValues("FileNumber") & "','" & e.NewValues("BOL") & "','" & e.NewValues("Container") & "','" & e.NewValues("DESTN") & "','" & e.NewValues("Comments") & "','" & e.Keys("LineIndex") & "')"
-
End If
-
Any ideas???
Thanks
4 2381
Is this code for a System.Data.DataTable update? Please clarify.
Is the data bound to a DataGrid?
What event are you using to trigger this update/insert?
Sounds like you are manually processing updates done manually in a DataGridView.
Do you have an additional DataAdapter.Update() statement that might be automatically updating the modified rows on its own?
Is this code for a System.Data.DataTable update? Please clarify.
Is the data bound to a DataGrid?
What event are you using to trigger this update/insert?
Sounds like you are manually processing updates done manually in a DataGridView.
Do you have an additional DataAdapter.Update() statement that might be automatically updating the modified rows on its own?
Yes, the data is bound to a Gridview when I enter INV #.
Event I'm using is DetailsView1_ItemUpdating. No additional Update statement!
Pl;ease remember to use [code] tags when posting code.
MODERATOR
Just a "by the way," you should learn how to use String.Format for building strings. Either that or System.Text.StringBuilder. Because reading long concatenated strings like that is painful, and hard to debug.
OK, you are using the actual DetailsView control, which I am not familiar with. Apologies, I thought you meant "details view" in a generic way and might be using a Forms.DataGridView with which I am more familiar.
Hopefully someone with more experience can help you. Nonetheless, sounds like ItemUpdating may be getting called twice...coders familiar with the control know these quirks and will tell you in a heartbeat.
In the meantime, maybe you could add some Trace statements to the ItemUpdating event handler and see if indeed it is getting called twice. Perhaps (longshot) after executing your sql it fires the updating event again? Try removing the "UPDATE part of your logic, so that it only inserts new records. If you don't get a duplicate, then it might mean it was firing an INSERT followed by an UPDATE for some reason.
Good luck.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Reply via newsgroup |
last post by:
Folks,
When performing an update in mysql (using PHP), can I find out how many
records were matched?
mysql_affected_rows() won't work... and I have the following problem
that I thought I...
|
by: kalamos |
last post by:
This statement fails
update ded_temp a
set a.balance = (select sum(b.ln_amt)
from ded_temp b
where a.cust_no = b.cust_no
and a.ded_type_cd = b.ded_type_cd
and a.chk_no = b.chk_no
group by...
|
by: VK |
last post by:
<http://www.jibbering.com/faq/#FAQ3_2>
The parts where update, replacement
or add-on is needed are in <update> tag.
3.2 What online resources are available?
Javascript FAQ sites, please...
|
by: jaYPee |
last post by:
I have search a lot of thread in google newsgroup and read a lot of
articles but still i don't know how to update the dataset that has 3
tables.
my 3 tables looks like the 3 tables from...
|
by: jaYPee |
last post by:
I am having a problem on how to update view from sql server 2000
database. I have tried dataset and sql dataadapter but no luck. I'm
using this view in datagrid and i want to update the datagrid if...
| |
by: PAUL |
last post by:
Hello,
I have 2 datasets I am trying to update. The parent table seems to
update fine but when I go update the chiled table I get an error message
that says I need a related record in the parent...
|
by: Zorpiedoman |
last post by:
I keep getting a concurrency exception the second time I make a change and
attempt to update a dataadapter. It appears this is by design, so there must
be something I can do to avoid it.
...
|
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,...
|
by: Stephen Plotnick |
last post by:
I'm very new to VB.NET 2003
Here is what I have accomplished:
MainSelectForm - Selects an item
In a public class I pass a DataViewRow to
ItemInformation1 Form
ItemInformation2 Form
|
by: rukkie |
last post by:
Hi,
I have a dynamic HTML page with 4 columns of data, retrieved with PHP
from a MySQL database.
At the end of every row I have an UPDATE submit button, which activates
a php update script to...
|
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: 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...
|
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: 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...
| | |