Site Search:
Sign in | Join | Help

Script to create classes in eConnect 8 and 9

Last post 07-21-2007 6:28 PM by Steve Gray. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 07-21-2007 6:28 PM

    Script to create classes in eConnect 8 and 9

    I use this script to create classes in eConnect 8 and 9. For 8, remove the comments to create the necessary 'specified' fields that are not documented

    Steps:

    • Copy the eConnect schema from help into Excel
    • Fix the column names
    • Add the 'intRowID' column, populate it
    • Import into SQL
    • Run the script below against the table. It will
      • clean up the Description column
      • create a class with all the properties that can be copied into VB

     

    DECLARE @elementName varchar(255)
    DECLARE @dataType varchar(255)
    DECLARE @length float 
    DECLARE @required varchar(255)
    DECLARE @defaultVal varchar(255)
    DECLARE @description varchar(255),
     @intLastValid as int,
     @intRowID int
    
    
     
    
    
    set nocount on
    select
     @intLastValid = 0
    
    
    DECLARE curPre CURSOR KEYSET FOR 
     select intRowID, elementName, datatype, length, required, [default], description from _sopline order by intRowID
    
    
    OPEN curPre
    FETCH NEXT FROM curPre INTO @intRowID, @elementName,@dataType,@length,@required,@defaultVal,@description
    WHILE (@@fetch_status = 0)  BEGIN
     if @elementName is null begin
      update _sopline set description = description + @description where intRowID = @intLastValid
      delete _sopline where intRowID = @intRowID
     end else begin
      set @intLastValid = @intRowID
     end 
    
    
    
     FETCH NEXT FROM curPre INTO @intRowID, @elementName,@dataType,@length,@required,@defaultVal,@description
    END
    
    
    CLOSE curPre
    DEALLOCATE curPre 
    
    
    DECLARE curname CURSOR KEYSET FOR 
     select * from _sopline order by required desc , elementname 
    
    
    OPEN curname
    FETCH NEXT FROM curname INTO @intRowID, @elementName,@dataType,@length,@required,@defaultVal,@description
    
    
    WHILE (@@fetch_status = 0)
    
    
     BEGIN
     /*
     if @datatype in ('i4','number') and not @elementname in ('potype') begin
      print 'private _' + @elementname + ' as string' + char(39) +case when @required = 'y' then '(required) ' else '' end + @description 
      print 'Public Property ' + @elementname + '() As String'
      print 'Get'
      print ' Return _' + @elementname 
      print 'End Get'
      print 'Set(ByVal value As String)'
      print ' _' + @elementname + ' = value'
      print ' Me.' + @elementname + 'specified = True'
      print 'End Set'
      print 'End Property'
      print 'public ' + @elementname + 'specified as boolean = false' 
      end else begin
     */
      print 'Public ' + @elementname + ' as string ' + char(39) +case when @required = 'y' then '(required) ' else '' end + @description 
    
    
     --end
     FETCH NEXT FROM curname INTO @intRowID, @elementName,@dataType,@length,@required,@defaultVal,@description
    
    
    END
    
    
    CLOSE curname
    DEALLOCATE curname 
    
    
    GO
    
    
    
     

     

    Steve Gray, MCDBA
    Technical Editor
    steve@VSToolsForum.com
    • 72.185.100.232
Page 1 of 1 (1 items)