Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to display a dialog box with which the user can add a data source (DSN)
Custom HttpRequest class (WinHTTP)
How to adjust monitor brightness (Vista, monitor with DDC support)
How to download a file from HTTP server using URL Monikers functions
How to retrieve adapter information for the local computer (including MAC address)
Reading security permissions for NTFS files and folders
Using named pipes for interprocess communication
Drawing standard Windows icons
How to block the ALT+TAB shortcut (WinXP)
GDI+: printing image file
How to Start a Process as Another User (NT/XP/2K)
Memory usage info for current VFP session (WinNT only)
Smart Card Database Query Functions
Using Path functions from Shell Lightweight Utility APIs (shlapi.dll)
Creating a unique filename based on existing filename
How to print FoxPro form -- II
Using Font and Text functions
How to find which fonts Windows uses for drawing captions, menus and message boxes
Storing registration key in the resources of an executable file
Creating the Save dialog box to specify the drive, directory, and name of a file to save
GDI+: Using Scale and Shear transformations
How to disable the Windows Clipboard (VFP9)
Analyzing character types in a specified string
How to retrieve the number of print jobs queued for the printer
How to display a dialog box with which the user can add a data source (DSN)

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Before you begin:
This is a dialog allowing you to create a new data source:


And later if you decide to modify existing data sources:

DO decl

IF Not CreateDSN("NewDSN")
* 16 = cancelled by the user
* 18 = Could not create a DSN in the registry
* ...
    = MessageB(GetErr(), 64, " Creating New Data Source")
ENDIF

* if you decide to manage data sources
= SQLManageDataSources(GetActiveWindow())

* end of main

FUNCTION CreateDSN(cDSN)
RETURN (SQLCreateDataSource(GetActiveWindow(), cDSN) <> 0)

FUNCTION GetErr
* returns error info for the ODBC installer functions
#DEFINE SQL_SUCCESS  0
#DEFINE SQL_SUCCESS_WITH_INFO 1

    LOCAL nIndex, cMsg, nBufsize, nErrCode,;
        cResult, nResult

    cResult = ""
    FOR nIndex = 1 TO 8
        nBufsize = 512
        cMsg = Repli(Chr(0), nBufsize)
        nErrCode = 0

        nResult = SQLInstallerError(nIndex, @nErrCode,;
            @cMsg, nBufsize, @nBufsize)

        IF INLIST(nResult, SQL_SUCCESS, SQL_SUCCESS_WITH_INFO)
            cMsg = SUBSTR(cMsg, 1, AT(Chr(0), cMsg)-1)

            cResult = cResult + Iif(nIndex=1, "", Chr(13)+Chr(13)) +;
                "Error code: " + LTRIM(STR(nErrCode)) + Chr(13) +;
                cMsg + ".     "
        ELSE
            EXIT
        ENDIF
    ENDFOR
RETURN cResult

PROCEDURE decl
    DECLARE INTEGER GetActiveWindow IN user32
    DECLARE INTEGER SQLManageDataSources IN odbccp32 INTEGER hwnd

    DECLARE INTEGER SQLCreateDataSource IN odbccp32;
        INTEGER hwnd, STRING lpszDS

    DECLARE INTEGER SQLInstallerError IN odbccp32;
        INTEGER iError, INTEGER @pfErrorCode, STRING @lpszErrorMsg,;
        INTEGER cbErrorMsgMax, INTEGER @pcbErrorMsg



User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1438 bytes  
Created: 2003-01-31 16:25:07  
Modified: 2009-01-03 15:26:33  
Visits in 7 days: 190  
Listed functions:
GetActiveWindow
SQLCreateDataSource
SQLInstallerError
SQLManageDataSources
Printer friendly API declarations
My comment:
ODBC Data Source Administrator
Word Index links for this example:
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
User Contributed Notes:
There are no notes on this subject.


Copyright 2001-2018 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.38), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.234.0.2)
2 sec.Updates
4 sec.Function: 'SHAddToRecentDocs'
Function group: 'Shell Functions'
6 sec.Function: 'waveInStart'
Function group: 'Windows Multimedia'
7 sec.
10 sec.Function: 'GetTextCharacterExtra'
Function group: 'Font and Text'
11 sec.Solutions
13 sec.Function: 'WSACleanup'
Function group: 'Windows Sockets 2 (Winsock)'
14 sec.Function: 'InternetAutodialHangup'
Function group: 'Internet Functions (WinInet)'
16 sec.Updates
17 sec.Function: 'SQLBrowseConnect'
Function group: 'ODBC API'
Google
Advertise here!