Subscribe to this thread
Home - General / All posts - C# Parameterized Query
Eddie12348 post(s)
#23-Apr-08 07:40

I have been trying to get this to work and have posted a couple question and so far I have not got anywhere. I am trying to use C# and the Manifold object model to pass a parameter to a query in a Map file. I found the following code in one of Manifold's examples and would you believe that it doesn't work! I have tried to port this over to C# (example below).

//Tracker Example script application

var queryLength = mapserver.Document.ComponentSet("QueryLength");

queryLength.ParameterSet(0).Value = wktLine;

queryLength.ParameterSet(1).Value = trackUnit;

queryLength.Run();

//My attempt at C# code

Manifold.Interop.Query q = (Manifold.Interop.Query)mapServer.Document.ComponentSet["LoadTickets Points Drawing"];

q.ParameterSet[0].Value = "10";

q.Run();

The problem seems to be that the object is not a Query, it seems to be a Manifold.Interop.DrawingClass. This does not make since because the DrawingClass does not have a ParameterSet property or a Run Property. But in the Manifold example it implies that it does. Can anyone help me out with this?

Thanks

Eddie

vincent

1,972 post(s)
#23-Apr-08 08:23

It cannot work because your are assigning "LoadTickets Points Drawing" to Manifold.Interop.Query q .

In the example you submit, a existing query is assigned to var queryLength :

var queryLength = mapserver.Document.ComponentSet("QueryLength").

You have to call a existing query component or create a new one to get access to query property.

To create a new one, use Document.NewQuery and then Query.Text to set the text of the query. If you have parameter, you can set them as mentionned above and then use Query.run().

I don't program in C#. Hope this help.

Vincent

Eddie12348 post(s)
#23-Apr-08 08:34

Thanks Vincent. You are exactly right. My point is how do you get a reference to an existing Query. I have looked at the documentation and the object model map and I can't find a way to get a reference to an existing query. I have used many variations of code that tries to follow the object model without success.

vincent

1,972 post(s)
#23-Apr-08 09:39

Did you try this :

Manifold.Interop.Query q = (Manifold.Interop.Query)mapServer.Document.ComponentSet("yourQueryName") ?

AR_Rick

128 post(s)
#23-Apr-08 10:05

Here's some C# code I lifted out of one of my projects for performing a Query:

Manifold.Interop.Query q = (Manifold.Interop.Query)this.searchMap.manifoldDoc.ComponentSet["Geocoder Query"];

// Run the Geocoding query by passing the input

q.ParameterSet["address"].Value = input;

q.RunEx(true);

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.