This question is locked. New answers and comments are not allowed.
Hi,
ive got table Contacts and second table ContactAddresses, ContactAddresses have reference to Contacts(in database) ive made in reverse mapping one-to-many so i have in Contacts collection of ContactAddresses. Ive got server app that makes transaction, and client app which creates contact object and send it over webservice to server app. it looks like:
On server:
public static string AddZus(Contact contact) |
{ |
string Error = string.Empty; |
IObjectScope scope = DBProvider.GetNewObjectScope(); |
scope.Transaction.Begin(); |
scope.Add(contact); |
try |
{ |
scope.Transaction.Commit(); |
} |
catch (Exception e) |
{ |
Error = e.Message; |
} |
return Error; |
} |
On client:
WebService.Contact contact = new WebService.Contact(); |
WebService.Contactaddress[] contactAddresses = new WebService.Contactaddress[1]; |
WebService.Contactaddress contactAddress = new WebService.Contactaddress(); |
contact.Description = descriptionTextBox.Text; |
contact.FullDescription = fullDescriptionTextBox.Text; |
contact.Comments = commentTextBox.Text; |
contactAddress.Address1 = address_1TextBox.Text; |
contactAddress.Address2 = address_2TextBox.Text; |
contactAddress.Address3 = address_3TextBox.Text; |
contactAddress.City = cityTextBox.Text; |
contactAddress.ContactAddressType = Enums.ContactAddressType.Main.ToString(); |
contactAddress.Country = countryTextBox.Text; |
contactAddress.Post = postTextBox.Text; |
contactAddress.Status = Enums.Status.Active.ToString(); |
contactAddress.ZipCode = zipCodeTextBox.Text; |
contactAddresses[0] = contactAddress; |
contact.Contactaddress = contactAddresses; |
string Error = EasyCRMService.AddZUS(contact); |
if (Error != string.Empty)MessageBox.Show(Error); |
when it executes ive got error:
Insert of '638682188-0' failed: Telerik.OpenAccess.RT.sql.SQLException: Column 'Contacts_ID' cannot be null |
at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute() |
at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute() |
at OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes) |
INSERT INTO `contactaddresses` (`ADDRESS_1`, `ADDRESS_2`, `ADDRESS_3`, `CITY`, `COMMENTS`, `Contacts_ID`, `CONTACT_ADDRESS_TYPE`, `COUNTRY`, `ID`, `POST`, `STATUS`, `ZIP_CODE`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) |
(set event logging to all to see parameter values) Telerik.OpenAccess.RT.sql.SQLException: Column 'Contacts_ID' cannot be null |
at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute() |
at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute() |
at OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes) |
what im doing wrong? and how can i fix it?