Kbase P65268: How to retrieve data from a Progress database into a .Net DataSet using SQL92 and ADO.Net
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  15/10/2008 |
|
Status: Verified
GOAL:
How to retrieve data from a Progress database into a .Net DataSet using SQL92 and ADO.Net
FACT(s) (Environment):
Progress 9.1x
OpenEdge 10.x
FIX:
The following sample VB.Net code shows how to retrieve data from a Progress database using SQL92 and ADO.Net and fill a .Net DataSet with the results:
' This Variable Will Be Bound To The UI DataGrid Control Using The
' DataSource Property Of The DataGrid Control
Dim SomeDataSet As New DataSet
' Instantiate ODBC Connection Object First As It Is Needed By The
' Command Object And Consequently The Adapter Object
Dim SQLConnection As New OdbcConnection("DSN=Some_ODBC_DSN;UID=SomeUser;PWD=SomePassword")
' Instantiate ODBC Adapter Which Hold Instances Of Our Command Objects
Dim SQLAdapter As New OdbcDataAdapter
' Instantiate Command Object With Desired SQL Command And What Connection
' Object It Will Execute Against
SQLAdapter.SelectCommand = New OdbcCommand("YourSelectCommandGoesHere", SQLConnection)
' All The Prep Work Has Been Completed So Now We Open The Connection
SQLConnection.Open()
' Now We Tell The Adapter To Load The Results Of The Command Object
' Defined As Its "SelectCommand" Property Into The Dataset
SQLAdapter.Fill(SomeDataSet)
' Now We Tell The DataGrid UI Control To Use The Loaded DataSet As
' The Source Object From Which It Will Display Data
SomeDataGridControl.DataSource = SomeDataSet
' Finally, We Close And Dispose Of The Objects The We No Longer Need
SQLAdapter.Dispose()
SQLConnection.Close()
SQLConnection.Dispose()