MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Create UDL from a connect string with code

This is a discussion on Create UDL from a connect string with code within the MapPoint 2006/2009 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 ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-23-2002
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 08-23-2002
John Meyer's Avatar
Senior Member
Blue Belt
 
Join Date: Jul 2002
Posts: 479
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!
__________________
John
http://www.support-pc.com

Order MapPoint 2006 Here
https://secure.mp2kmag.com/?refer=support-PC
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
code, connect, create, string, udl


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
MappointControl OpenMap filename string length limitation malejo MapPoint 2006/2009 Discussion 1 07-02-2005 03:55 AM
How to create Postal Code Boundries? Anonymous MapPoint 2006/2009 Discussion 6 06-24-2004 06:25 PM
MapPoint 2004-Create Territories Using Full Cdn Postal Code wkcarreg MapPoint 2006/2009 Discussion 1 01-30-2004 12:46 PM
Drawing contour lines from nodes in a string file Anonymous MapPoint 2006/2009 Discussion 1 10-29-2003 10:30 AM
Validate Address String pgrooms MapPoint 2006/2009 Discussion 1 11-07-2002 05:30 AM


All times are GMT -5. The time now is 07:00 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


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