Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 10 of 10

Using Mappoint COM object through SQL Server

This is a discussion on Using Mappoint COM object through SQL Server within the MapPoint Desktop Discussion forums, part of the Map Forums category; I have created a Active X DLL object in VB6 that uses Map Point to calculate the Long/Lat of a ...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    Using Mappoint COM object through SQL Server

    I have created a Active X DLL object in VB6 that uses Map Point to calculate the Long/Lat of a given Post Code. When used in a test application, the object performs fine. I am now trying to use the same object within SQL Server 2000 (using the CreateObject syntax). The object initialises fine but as soon as it tries to open an instance of MapPoint.Application it fails with an Active X cant create object error. Is what I'm doing impossible or am I missing something?

    Any help would be appreciated.

    Thanks.

  2. #2
    bigRahn is offline Member Yellow Belt
    Join Date
    Oct 2002
    Posts
    46

    how about a code fragment

    Can you post a fragment of your code showing how you're initalizing the application object? That may help debug it.

    Are you doing this within a DTS or something? One thing that pops in my head is if you have a lot of users hitting your DB, it may be failing due to stress...have a 100 instances of MP open may be causing a problem.

    -Rahn

  3. #3
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    The map point COM object is a basic Active X DLL. It has a Reference in it to the MapPoint 9.0 Object Library (Europe). It has an object variable (Mapt) declared as MapPoint.Application.

    There is a method in the object called Start_MapPoint which simply calls
    SET Mapt = NEW MapPoint.Application.

    The initial lines of the stored procedure are as follows:

    CREATE PROCEDURE aaGetLongLat(
    @Pcode varchar(20))
    AS

    DECLARE @Object int
    DECLARE @hr int
    DECLARE @Property varchar(255)
    DECLARE @Return varchar(255)
    DECLARE @src varchar(255)
    DECLARE @Desc varchar(255)
    DECLARE @PropLong float
    DECLARE @PropLat float

    PRINT 'Creating Object'

    -- Create an Object
    EXEC @Hr = sp_OACreate 'MapPointServer.clsLongLat',@Object OUT

    IF @Hr <> 0
    BEGIN
    EXEC sp_OAGetErrorInfo @Object,@src OUT,@Desc OUT
    SELECT hr = CONVERT(varbinary(4),@hr),Source = @src,Description = @Desc
    RETURN
    END

    PRINT 'Set Properties'

    --Set the Properties
    EXEC @Hr = sp_OASetProperty @Object,'PostCode',@Pcode
    IF @Hr <> 0
    BEGIN
    EXEC sp_OAGetErrorInfo @Object,@src OUT,@Desc OUT
    SELECT hr = CONVERT(varbinary(4),@hr),Source = @src,Description = @Desc
    RETURN
    END

    Print 'Starting Map Point'
    EXEC @hr = sp_OAMethod @Object, 'StartMapPoint'
    IF @Hr <> 0
    BEGIN
    EXEC sp_OAGetErrorInfo @Object,@src OUT,@Desc OUT
    SELECT hr = CONVERT(varbinary(4),@hr),Source = @src,Description = @Desc
    RETURN
    END

    The rest of the code is irrelevant because it doesn't run past this point in the code.

    The output if I run this in Query analyser is:

    Creating Object
    Set Properties
    Starting Map Point
    0x800A01AD - ActiveX component can't create object.

  4. #4
    bigRahn is offline Member Yellow Belt
    Join Date
    Oct 2002
    Posts
    46

    I made some progress

    I think the problem may be with how mappoint is instantiated within the dll.
    I created 2 sample dlls as follows:

    1. mpClassApp: creates the mappoint object as mappoint.application
    2. mpClassMap: creates the mappoint object as mappoint.map

    I put together a very simple SQL script to open up each dll and print out the return error codes.

    When opening mpClassMap, it worked fine.
    mpClassApp created an error and failed to open MP.

    instead of posting all the code here, I threw a zipped file at:
    http://home1.gte.net/res05fqx/rahn/projects/MpTest.zip

    Let me know what you think. I'm curious to see where this goes and the resolution.
    If anyone thinks I'm way off base, I'd like to hear :D

    Rahn

    Oh, note I'm running XP Pro, SQL Server 2000 Development edition for this. Not sure how much dev edition of the SQL server will make a difference.

  5. #5
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    The error you are getting in your .application class is due to a typo in your SQL statement. Instead of

    exec @Hr = sp_OACreate 'aclsTest,mpClassApp', @Object OUT

    it should read:

    exec @Hr = sp_OACreate 'aclsTest.mpClassApp', @Object OUT

    When I run your test code, I get the same error in both cases, the error message however is NULL. This is the problem I was experiencing when creating an instance of the object in the Initialize Event of the class. That is why I created the StartMapPoint method, to prove that at least my object was being created and then you seem to get proper error messages returned.

  6. #6
    bigRahn is offline Member Yellow Belt
    Join Date
    Oct 2002
    Posts
    46

    oops.

    :oops:
    guess typos happen when I'm trying something while tired and the wife is talking to me in the background.

    Interesting though, the mpClassMAP method did fire up mappoint for me.
    I'd guess I could use some better error handling, which would point out where the error is coming from instead of returning a generic OLEDB message.

    I'll try to play with it more tonight or tomorrow.

  7. #7
    bigRahn is offline Member Yellow Belt
    Join Date
    Oct 2002
    Posts
    46

    oh. here's a dumb question

    I look a quick look on MSDN for your error number and got this:
    http://support.microsoft.com/default...b;en-us;298926

    (Yes, I know this article is for terminal services/IIS.)
    Implies that it's a permission problem. Have you played with the permissions at all to see if that makes a difference?

  8. #8
    bigRahn is offline Member Yellow Belt
    Join Date
    Oct 2002
    Posts
    46

    no progress, working fine for me...

    I added a method to the mpClassApp, so I could try calling it to simulate your SQL better.
    No such luck...worked fine with my machine. Which leads me back to my previous post of having the right permissions.

    I've updated the ZIP file at the location above with the new class code and the new SQL statements.
    The method works great :)

    -Rahn

  9. #9
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    I really appreciate this help.

    I'm running all this stuff locally on the Windows 2000 Server that has the SQL Server database on it. It also has Map Point installed on it locally.

    I have proved my object is being created OK and it is the Map Point object that is failing. Not being very techy when it comes to Comms/Networking etc, please could you tell me where I need to set permissions to allow SQL Server to access the Mappoint application objects.

    Thanks

  10. #10
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    I've done it!!!!!

    You were right, it was a permissions problem on the server. I added the DLL's to the COMs lists and it worked first time.

    Thanks again for all you help, it's much appreciated. :D

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Drawing on mappoint object
    By vidyakulkarni in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 08-05-2004, 09:28 AM
  2. MapPoint and Web Server
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 11-05-2003, 12:58 AM
  3. Adding MapPoint COM Object to .NET Web Service
    By ChrisC in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 09-30-2003, 07:13 PM
  4. route object to drawing object
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 05-09-2003, 10:29 PM
  5. Pixelated Mappoint Object in Powerpoint
    By amyles in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 04-23-2003, 06:08 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25