Community of VE/MapPoint Users and Developers
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 ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Create UDL from a connect string with code 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 |
| ||||
|
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 |
![]() |
| Tags |
| code, connect, create, string, udl |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| 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 |