Application Delivery Management
Application Modernization & Connectivity
CyberRes
IT Operations Management
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.
working-storage section.
exec sql include sqlca end-exec.
exec ado
declare emptb datatable
( empid int32
,empname string(10)
)
end-exec.
exec ado
declare empds dataset for emptb
end-exec.
method-id NEW.
procedure division.
invoke self::InitializeComponent
goback.
end method.
method-id button1_Click final private.
local-storage section.
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"
end method.
method-id createdataset.
local-storage section.
01 obj object.
procedure division returning myds as type DataSet.
exec ado
using empds initialize dataset returning :obj
end-exec
exec ado
insert into emptb (empid, empname)
values (1, 'Evan')
end-exec
exec ado
insert into emptb (empid, empname)
values (2, 'John')
end-exec
exec ado
accept changes for emptb
end-exec
set myds to obj as type DataSet
end method.
end class.
8321.DisconnectedADOSample.zip