NOTICE: Our Community is moving. Get more information.
I have data available in my COBOL program(data could be from sub-programs or data files etc.). How can I bind the data to DataGridView using disconnected ADO.NET?
You can use our OpenESQL technology to first declare the ADO datatable and dataset. Then use the EXEC ADO INITIALIZE statement to create the dataset and return a reference to the dataset. After the ADO dataset is created, you can use EXEC ADO INSERT statements to insert data to the datatable just like the traditional embeded EXEC SQL statements. The returned dataset object can be used in binding.
The sample code is below and the project is attached.
class-id DisconnectedADOSample.Form1 is partial
inherits type System.Windows.Forms.Form.
exec sql include sqlca end-exec.
declare emptb datatable
( empid int32
declare empds dataset for emptb
method-id button1_Click final private.
01 ds type DataSet.
procedure division using by value sender as object e as type System.EventArgs.
set ds to self::createdataset
set dataGridView1::DataSource to ds
set dataGridView1::DataMember to "emptb"
01 obj object.
procedure division returning myds as type DataSet.
using empds initialize dataset returning :obj
insert into emptb (empid, empname)
values (1, 'Evan')
values (2, 'John')
accept changes for emptb
set myds to obj as type DataSet