[Progress Communities] [Progress OpenEdge ABL] Forum Post: .NET FRAMEWORK AND OE

  • Thread starter Giancarlo Alberto Somma
  • Start date
Status
Not open for further replies.
G

Giancarlo Alberto Somma

Guest
Hi to all, Could you pls suggest me which is better way for to use .NET with OE 11.7? Follow the code that I need to run in OE. Many thanks. A. Sample code enhanced with error and exception handling: // Step #1: Create Connection object oneSage.SDK.RD.Access.Connection lConnection = new oneSage.SDK.RD.Access.Connection("SageStart", @"@user=;@password=;" + "@path=!Srv!Standard:myServerName/" + "C:/Sage Data/Folders/Meine Firma/SageStart/Meine Firma.SgWwr", "SageStart"); oneSage.SDK.RD.Validating.InfoList lInfoList = new oneSage.SDK.RD.Validating.InfoList(); if (lConnection.DoValidate((oneSage.SDK.RD.Validating.Interface.IInfoList)lInfoList) == true) { try { // Step #2: Create Adapter object oneSage.SDK.RD.Access.Adapter lAdapter = new oneSage.SDK.RD.Access.Adapter(lConnection); // Step #3: Create data set, tables, rows for data operations // Create new and empty Sage Start data set oneSage.SDK.RD.Data.SageStart lDataSet = new oneSage.SDK.RD.Data.SageStart(); oneSage.SDK.RD.Data.SageStart.AccountDataTable lTbl = lDataSet.Account; oneSage.SDK.RD.Data.SageStart.AccountRow lRow = lTbl.NewAccountRow(); lRow.AccCode = "9999"; lRow.DescDe = lRow.DescFr = lRow.DescEn = lRow.DescIt = "My new account"; lTbl.AddAccountRow(lRow); // Step #4: Execute SDK operation (Insert) and write all rows the database lAdapter.Execute(oneSage.SDK.RD.Access.Operation.Insert, lDataSet, lTblName, lInfoList); } catch (SystemException lExp) { // Catch any exception thrown by the .NET data set (e.g. Primary Key, AllowDBNull, ReadOnly) // Show error by re-using SDK's InfoList lInfoList.Add(new oneSage.SDK.RD.Validating.Info(oneSage.SDK.RD.Validating.InfoTypes.Error, DateTime.Now, lExp.Message, "MyApplication", "Manipulating data set")); } // Show error messages if any System.Text.StringBuilder lMessageBuilder = new StringBuilder(); foreach (oneSage.SDK.RD.Validating.Info lInfo in lInfoList) { if ((int)lInfo.InfoType < (int)oneSage.SDK.RD.Validating.InfoTypes.CriticalError) { lMessageBuilder.Append(lInfo.InfoType + " (" + lInfo.DateTime + "): " + lInfo.Method + "/" lInfo.Message + "\r\n"); } } if (!string.IsNullOrEmpty(lMessageBuilder.ToString())) MessageBox.Show(lMessageBuilder.ToString(), "Info List", MessageBoxButtons.OK, MessageBoxIcon.Information); }

Continue reading...
 
Status
Not open for further replies.
Top