General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Cursor Adapter class : insertion - one to many
Hi everyone. I have one primary table link to a foreign table. This is a one to many relationship. SQL Server back end
Primary Table Foreign table
Sample : Field name : ctrlno ctrlno
Field type : integer integer
Identity : Yes No
Purpose : using cursor adapter how can i replace the foreign key (ctrlno) with the autogenerated value of the primary field name.
Problem : Using the following program, would itemdtls.ctrlno inherit the auto generated value of invoice.ctrlno? Both tables are not updated.
Program :
Define Class clsArinv as CursorAdapter
AllowUpdate = .T.
AllowDelete = .T.
AllowInsert = .T.
SendUpdates = .T.
DataSourceType = "ODBC"
selectcmd = [select invoice.ctrlno, itemdtls.itemid ; from invoice, itemdtls where invoice.ctrlno = ;
itemdtls.ctrlno and arinv.ctrlno = ?nctrlno]
CursorSchema = [ctrlno i(4), itemid c(20)]
Tables = "invoice, itemdtls"
UpdatableFieldList = "ctrlno,itemid"
UpdateNameList = "ctrlno invoice.ctrlno, itemid itemdtls.itemid"
Procedure Init
*-- Add a property at run-time that holds a Connection Handle.
This.AddProperty('Connection',SQLSTRINGCONNECT(pvConnString))
*-- The data source is our Connection Handle
This.DataSource = This.Connection
EndProc
ENDDEFINE
Thanks in advance.
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only