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 2 of 2

Create UDL from a connect string with code

This is a discussion on Create UDL from a connect string with code within the MapPoint Desktop Discussion forums, part of the Map Forums category; For what it is worth, here is a VB6 function to create a UDL on the fly. The real trick ...

  1. #1
    kdybvik is offline Junior Member White Belt
    Join Date
    Aug 2002
    Posts
    3

    Create UDL from a connect string with code

    For what it is worth, here is a VB6 function to create a UDL on the fly. The real trick was learning of the two hex items before the [oledb]. Thanks to various google postings...

    Use at your own risk, not representing the views of my company, blah, blah.

    Private Function CreateUDL(ByVal OLEDB_ConnectString As String) As String
    Dim sUDLFile As String
    Dim sUDLText As String
    Dim nFile As Integer
    Dim B As Byte

    '*** text for body of UDL
    sUDLText = "[oledb]" & vbCrLf & _
    "; Everything after this line is an OLE DB initstring" & vbCrLf & _
    OLEDB_ConnectString & vbCrLf

    '*** needs to be Unicode, so convert it
    sUDLText = StrConv(sUDLText, vbUnicode)

    '*** temporary filename based on app info
    sUDLFile = App.Path & "\" & App.EXEName & ".udl"

    '*** delete file if it already exists
    If (Len(Dir$(sUDLFile)) > 0) Then
    Kill sUDLFile
    End If

    '*** open the file for binary writing
    nFile = FreeFile
    Open sUDLFile For Binary Access Write As #nFile

    '*** UDL files must start with Hex FF and FE
    B = &HFF
    Put #nFile, , B
    B = &HFE
    Put #nFile, , B

    '*** write the rest of the info to the file
    Put #nFile, , sUDLText

    '*** always close the file
    Close #nFile

    '*** return the complete filename
    CreateUDL = sUDLFile

    End Function

  2. #2
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    Excellent code...

    For those of you who do not know what a udl file is: In the mappoint import data wizard you can choose to open a Microsoft Data Link file (filename.udl).

    You can create a UDL file by creating a blank txt document and giving it a udl extention. Then right click you Blank document and choose properties.
    at this point it should be self-explanatory. Choose you database server, database, password stuff etc... This will create your connection string and save it to the file you created.

    Now you can re-create this file thru code. Awsome!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. MappointControl OpenMap filename string length limitation
    By malejo in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 07-02-2005, 02:55 AM
  2. How to create Postal Code Boundries?
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 6
    Last Post: 06-24-2004, 05:25 PM
  3. MapPoint 2004-Create Territories Using Full Cdn Postal Code
    By wkcarreg in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-30-2004, 11:46 AM
  4. Drawing contour lines from nodes in a string file
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 10-29-2003, 09:30 AM
  5. Validate Address String
    By pgrooms in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-07-2002, 04:30 AM

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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83