Hi,
I have noticed a strange behaviour of CurrencyManager objects in C# (I
use Visual Studio 2005 Professional Edition).
Suppose that you have a SQL Server database with 2 tables called
"Cities" and "Persons", and that:
"Cities" has 2 fields called "IDCity" and "NameCity"
"Persons" has 3 fields called "IDPerson", "NamePerson " and
"IDCityAddr ess"
with "IDCity" and "IDCityAddr ess" fields relationed with the
classical father-child relation (the value for "IDCityAddr ess" is
required, you can't set it to null).
Suppose to define 2 DataTable objects called "dtCities" and
"dtPersons" (bound to the 2 tables), and 2 CurrencyManager objects
in this way:
cmCities = (CurrencyManage r)BindingContex t[dtCities];
cmPersons = (CurrencyManage r)BindingContex t[dtPersons,
"Cities_Persons "];
(where "Cities_Persons " is the relation that binds "IDCity" of
"dtCities" to "IDCityAddr ess" of "dtPersons" ).
Now, think to insert a new city with the statement:
cmCities.AddNew ();
and, before confirming the "dtCities" record insertion with the
cmCities.EndCur rentEdit() statement, insert a new person with the
statement:
cmPersons.AddNe w();
(of course in the C# form there will be some TextBox controls bound to
the various fields of the 2 current records of the tables).
Ok, now you can't confirm the "dtPersons" record insertion with
the cmPersons.EndCu rrentEdit() statement before confirming the
"dtCities" record insertion (the "IDCityAddr ess" value is
required in "dtPersons" , and that value doesn't exist yet in the
"IDCity" field of "dtCities") , so you must necessarily give
this order to the statements:
cmCities.EndCur rentEdit();
cmPersons.EndCu rrentEdit();
but when the first statement is executed, cmPersons.Posit ion is set to
-1, and the "dtPersons" new record isn't saved in
"dtPersons" .
This behaviour doesn't happen if I add a "dtPerson" record during
the modify of a "dtCities" record (cmPersons remains set to its
value and the cmPersons.EndCu rrentEdit() statement saves the new record
correctly, adding it to the table).
Can you explain me why??? Is there a way to insert a person during the
insertion of a city without being forced to introduce other additional
code?
Thank you very much 0 3848 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Christopher Benson-Manica |
last post by:
I have some markup like the following:
<form>
<table>
<script>
<!-- Write the table markup //-->
</script>
</table>
<form>
|
by: Jon Trelfa |
last post by:
I have been fighting with this script for several days and I'm finally
at the end of my rope. Here's the scenario:
-I have to add an entry into 1 table, called "calendar"
-I must retrieve the newly created autonumber field from this record
-Use the new ID number and insert it into a second table called
"cal_details"
--------------Begin Code--------------------
connString = "dsn=atpm"
|
by: William Ortenberg |
last post by:
I'm creating a new row in a table with via the AddNew method, where the
table ID is an Autonumber field. I want to capture the value of the ID
after I create the row. There are no other unique indices in the
table. Can I do this?
Thanks in advance.
|
by: hazz |
last post by:
if i have a table record called Rule 1 with
1. table name
2. table column name
3. operator (>,< =)
4. value (0 to n)
5. score
how could I create code to create a rule automatically so that i could
create an object to compare to these rules in the database.
|
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 table. However I put some
code in to display the key field of each parent table record (parent
dataset) and the value I am trying to put into the child table is there.
ParentTable ChildTable
ID------------------------<...
| |
by: Thammarat charoenchai. |
last post by:
After I use BindingSource.AddNew Method. (in my code is
OrderBindingSource.AddNew).
How can I set field value.
like
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
|
by: back100y |
last post by:
I have an application where I am using a DataGridView control to display DataTables stored in a DataSet. What I need to do is be able to prevent a user from adding a new if there is already a certain number of rows in the table. In addition, when the user deletes a row I need to be able to see the contents of that row and modify other rows in the DataTable appropriately.
From what I understand of the DataGridView controls interaction with...
|
by: salzan |
last post by:
Hello,
I'm trying to insert a new record in my recordset using AddNew method. I can't figure out how to declare values for the controls in my recordset. Can someone give me an example.
Thank you in advance for your help.
Salzan
|
by: salzan |
last post by:
The code below works in that I can insert records into the recordset.
Sub SaveRecord()
With rsRecord
.AddNew
! = Me!Proj_Id
! = Me!Proj_Name
! = Me!Cat_Id
.Update
End With
|
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: 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...
| |
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...
| |