Running ADO through webservice call

Fommo
Member Posts: 138
Hi
I have some old integration code that have worked perfectly fine in previous versions, but now in 2009 we get problems when running through webservice. The main idea is that we would like to run without NAS and be able to call the integration code through VS so that the peripheral system can get the control over when the integration is run.
BUT, the following ADO code gives us problem:
How come? Is it possible to avoid the somewhat crazy assign (the variant conversions) or is it possible to solve this situation. I guess that the variant conversion works with NAS as NAS is running more close to the NAV core and webservice is run on the service tier on a higher layer, right? Is it possible to write the code without using VARIANT variables? ](*,)
Please help
/Simon
I have some old integration code that have worked perfectly fine in previous versions, but now in 2009 we get problems when running through webservice. The main idea is that we would like to run without NAS and be able to call the integration code through VS so that the peripheral system can get the control over when the integration is run.
BUT, the following ADO code gives us problem:
EstablishDBConnectionWRefresh(pRefreshConnection); IF NOT ISCLEAR(ADOCommand) THEN // Recreate Command object CLEAR(ADOCommand); CREATE(ADOCommand); ADOConnStatus := MFLADOConnection.State; ADOConnString := MFLADOConnection.ConnectionString; MFLADOConnVariant := MFLADOConnection; ADOCommand.ActiveConnection := MFLADOConnVariant; //THIS LINE BLOWS ADOCommand.CommandText := pMainCommand + pArguments; ADOCommand.CommandType := StrToInt(pCmdType); ADOCommand.CommandTimeout := 0; CREATE(tmpADORecordSet); tmpADORecordSet.Open(ADOCommand);Note that this code works perfectly fine with NAS and has worked for years now, but when calling this code through a webservice call it blows on the marked (commented) line. I get the failure "The expression Variant cannot be type-converted to string".
How come? Is it possible to avoid the somewhat crazy assign (the variant conversions) or is it possible to solve this situation. I guess that the variant conversion works with NAS as NAS is running more close to the NAV core and webservice is run on the service tier on a higher layer, right? Is it possible to write the code without using VARIANT variables? ](*,)
Please help
/Simon
0
Comments
-
Have you tried
ADOCommand.ActiveConnection := MFLADOConnection;
Also I don't see in your code making the connection.
MFLADOConnection.ConnectionString := 'sql blah blah';
MFLADOConnection.Open;
I'm guessing you just omitted it from the post.0 -
ara3n wrote:Have you tried
ADOCommand.ActiveConnection := MFLADOConnection;Type conversion is not possible because 1 of the operators contains an invalid type. Integer := Automation
Which is quite right. It is an automation. It's irritating though that I have to go through a variant to assign it.ara3n wrote:Also I don't see in your code making the connection.
MFLADOConnection.ConnectionString := 'sql blah blah';
MFLADOConnection.Open;
I'm guessing you just omitted it from the post.0 -
Your code should work and I suggest to test it in 2009 sp1 and if you still get the error, I suggest to contact MS.0
-
Did you find a solution ?
We have the same problem. If we try the codeunit who uses ADO in a form no problem if we use it as webservice like
textBox2.Text= NAVWebService.LastlocationTractor(textBox1.Text);
we receive an error
System.Web.Services.Protocols.SoapException was unhandled
Message=The expression Variant cannot be type-converted to a String value.
Source=System.Web.Services
Actor=""
Lang=nl-BE0 -
0
-
lol I ran into the same issue.
So I posted the solution.
0 -
I searched around and I have found the solution for those that cannot upgrade to 2009 R2 for some reason:
gtxtQuery := //*** Some Query String ***// CREATE(gautADOConn); CREATE(gautADORecordSet); gautADOConn.ConnectionString := //***Some Connection String***// gautADOConn.Open; gautADORecordSet := gautADOConn.Execute(gtxtQuery); WHILE NOT gautADORecordSet.EOF DO BEGIN //*** Some record processing *** gautADORecordSet.MoveNext; gautADOConn.Close;
This works in both Classic and RTC0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions