ADOConnection on serverice tier (RTC)

ara3nara3n Member Posts: 9,256
edited 2013-10-28 in NAV Three Tier
Hello

Has anybody tried and run the ADO automation on service tier?

viewtopic.php?f=5&t=23038&hilit=lADOConnection

Based on this example, this doesn't work on RTC but works fine on classic.
//lvarActiveConnection is of type variant

lvarActiveConnection := lADOConnection;

//this is where it errors out when on RTC 
lADOCommand.ActiveConnection := lvarActiveConnection;

The error is
The expression Variant cannot be type-converted to a String value.

If I change the code to
lADOCommand.ActiveConnection := lADOConnection;

The compiler errors out
Type conversion is not possible because 1 of the operators contains an invalid type.

Integer := Automation
Ahmed Rashed Amini
Independent Consultant/Developer


blog: https://dynamicsuser.net/nav/b/ara3n

Comments

  • ara3nara3n Member Posts: 9,256
    So nobody has tried to use ADO automation on RTC?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • deV.chdeV.ch Member Posts: 543
    I have seen ADO connection on a NAV Module (Orderbase) and i encountered problems with it, because classic & Service Tier seem to handle the automation different.
    I can't tell you whats the problem, but what i have seen is that there has changed things from classic to RTC.

    Unfortunatly in the code i've seen the ADOConnection var is not further assigned to a var of type Command, execute is directly called with a string in it, so no solution for your problem, sorry...
  • ara3nara3n Member Posts: 9,256
    Thanks. For right now I'll run the solution on NAS. I will see if I can find another solution. Probably .NET framework.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • KisuKisu Member Posts: 381
    We run this and have stumbled upon same error.

    We are planing to run the automation with NAS service to go around it.
    K.S.
  • ara3nara3n Member Posts: 9,256
    I have written another solution. Here it its


    http://mibuso.com/blogs/ara3n/2011/01/1 ... tc-in-nav/
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • KisuKisu Member Posts: 381
    Nifty,
    I actually found another solution for this which seems to work fine. I made a simple test with it too for retreaving customer names to another test table:

    Here is the code:
    { // Globals: 
    txtQuery	 		Text		250
    autADOConnection	 	Automation	'Microsoft ActiveX Data Objects 2.8 Library'.Connection	
    autADORecordSet	 	Automation	'Microsoft ActiveX Data Objects 2.8 Library'.Recordset	
    recTestitaulu	 	Record	 	testi	
    }
    
    // SQL Kyselyn alustus / SQL Query
    txtQuery := 'SELECT * FROM [Your Company$Customer]'; // Customer table for the test
    
    // Automaatioiden alustus / Automation creations
    CREATE(autADOConnection);
    CREATE(autADORecordSet);
    
    // Tietokantayhteys / Database connection string
    autADOConnection.ConnectionString := 	'Driver={SQL Server};'
                                   	+ 'Server='+'PalvelimenNimi'+';' // Server name
                                   	+ 'Database='+'TietokannanNimi'+';' // Database name
                                   	+ 'Uid=UserName;' // Query user (remember rights)
                                   	+ 'Pwd=UserPassword;'; // user's password
    
    // Tietokantayhteyden avaus / DB connection open
    autADOConnection.Open;
    
    // SQL Kyselyn ajo avattuun kantaan sekä tietojen tuonti RecordSet Automaatiomuuttujaan / Query execution and retreaval for record set
    autADORecordSet := autADOConnection.Execute(txtQuery);
    
    
    recTestitaulu.RESET;
    
    // Looppi RecordSetin läpi / Loop through record set
    WHILE NOT autADORecordSet.EOF DO BEGIN
    
      // Uuden rivin luonti testitauluun / New line per record
      recTestitaulu.INIT;
      recTestitaulu.No := autADORecordSet.Fields.Item('No_').Value; // Perusavain Sarake 1 / Prikey yada yada
      recTestitaulu.Name := autADORecordSet.Fields.Item('Name').Value; // Nimi tieto Sarake 2 / some value
      recTestitaulu.INSERT;
    
      autADORecordSet.MoveNext; // Siirtymä seuraavaan RecordSetin riviin / next record
    
    END;
    
    autADOConnection.Close;
    
    K.S.
  • EnricosFollyEnricosFolly Member Posts: 4
    ara3n wrote:
    //lvarActiveConnection is of type variant
    lvarActiveConnection := lADOConnection;
    //this is where it errors out when on RTC 
    lADOCommand.ActiveConnection := lvarActiveConnection;
    
    The error is
    The expression Variant cannot be type-converted to a String value.

    Greetings,

    I run into this all the time. I think it is an incompatibility between design and execution in the compiled code of the program. (A Bug.)

    My resolution is so simple that it's silly. Nonetheless, it works.

    I save my code object without compiling. I re-open the object and compile it. It has taken several attempts at times to get this to work. Eventually, I always win over the machine.

    Once I remember closing Navision entirely and re-opening the application and re-opening the object before it would compile without the nasty little error message.
    Enrico's Folly
    Heat = Work
    And all things tend to chaos
  • alsolalsol Member Posts: 243
    I just tried it with an ADO connection that works on the classic client.

    On the RTC, somehow it does even not find the data source. From where does it select the data source, shouldn't it be selected from the client?
  • mtlmonkmtlmonk Member Posts: 48
    ara3n wrote:
    I have written another solution. Here it its


    http://mibuso.com/blogs/ara3n/2011/01/1 ... tc-in-nav/


    hi ara3n,

    What is the dotnet type (subtype) you have used to declare the variables (sqlconnection for example)?

    thanks in advance
  • ara3nara3n Member Posts: 9,256
    System.Data.SqlClient.SqlConnection
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • BhavnaBeedaseeBhavnaBeedasee Member Posts: 5
    Hello ara3n ,

    I am trying to access the http://mibuso.com/blogs/ara3n/2011/01/1 ... tc-in-nav/ site but it's not available. Can you please provide the address again.

    Thanks
    Bhavna
Sign In or Register to comment.