Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Custom GDI+ class
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Converting Unicode data from the Clipboard to a character string using a given code page
How to download a file from the FTP server using FtpGetFile
Detecting changes in connections to removable drives (VFP9)
Winsock: sending email messages (SMTP, port 25)
Enumerating data formats currently available on the clipboard
How to play AVI file on the _screen
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
Custom FTP Class for Visual FoxPro application
Custom HttpRequest class (WinHTTP)
Deleting files into the Recycle Bin
Creating the Open dialog box to specify the drive, directory, and name of a file to open
How to activate Windows Calculator
Splash Screen for the VFP application
Custom HttpRequest class (WinINet)
Using Font and Text functions
Establishing connection using the SQLDriverConnect
Mapping and disconnecting network drives
How to display the Properties dialog box for a file (ShellExecuteEx)
How to convert a bitmap file to monochrome format (1 bpp)
Using EnumPrinters function to enumerate locally installed printers
Establishing connection using the SQLDriverConnect

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
Versions:
click to open
 
#include "stdafx.h"
#include "conio.h"
#include < windows.h >
#include < sql.h >
#include < sqlext.h >
 
void GetConnected(unsigned char *conn)
{
    SQLHANDLE henv;
    SQLRETURN rc;
    SQLHANDLE hconn;
    SQLSMALLINT bufsize=0;
    SQLINTEGER nativeerror=0;
    SQLSMALLINT textlen=0;
    unsigned char connStrOut[256];
    unsigned char sqlstate[32];
    unsigned char message[256];
 
    rc = SQLAllocEnv(&henv);
    if (rc != SQL_SUCCESS)
    {
        printf("\nSQLAllocEnv call failed.");
        return;
    }
 
    rc = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hconn);
    if (rc != SQL_SUCCESS)
    {
        SQLFreeHandle(SQL_HANDLE_ENV, henv);
        printf("\nSQLAllocHandle call failed.");
        return;
    }
 
    rc = SQLDriverConnect(hconn, NULL, 
        conn, SQL_NTS, 
        connStrOut, 256, &bufsize, 
        SQL_DRIVER_NOPROMPT);
 
    if (bufsize!=0)
    {
        printf("Connected successfully.\n");
        SQLDisconnect(hconn);
    }
    else
    {
        rc = SQLGetDiagRec(SQL_HANDLE_DBC, hconn, 1, 
            sqlstate, &nativeerror, message, 256, &textlen);
 
        printf("SQLDriverConnect failed.\n");
        if (rc!=SQL_ERROR)
            printf("%s=%s\n", (CHAR *)sqlstate, (CHAR *)message);
    }
 
    SQLFreeHandle(SQL_HANDLE_DBC, hconn);
    SQLFreeHandle(SQL_HANDLE_ENV, henv);
}
 
void _tmain()
{
    GetConnected((unsigned char *)
        "DRIVER=SQL Server;SERVER=sql.someserver.com,1433;UID=admin;PWD=sa;");
    getch();
}
 
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1352 bytes  
Created: 2002-03-21 20:29:32  
Modified: 2011-12-10 09:20:22  
Visits in 7 days: 207  
Listed functions:
GetActiveWindow
SQLAllocEnv
SQLAllocHandle
SQLConnect
SQLDisconnect
SQLDriverConnect
SQLFreeEnv
SQLFreeHandle
SQLGetDiagRec
Printer friendly API declarations
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-2013 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.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.224.79.93)
3 sec.Example: 'How to prevent users from accessing the Windows Desktop and from switching to other applications'
2.07 hrs.Example: 'Retrieving the User Datagram Protocol (UDP) listener table'
 Example: 'Using File Mapping for enumerating files opened by Visual FoxPro'
3.34 hrs.Function: 'NetUserEnum'
 Function: 'RegEnumValue'
Function group: 'Registry'
4.31 hrs.Function: 'CM_Get_Sibling_Ex'
 Function: 'HeapReAlloc'
6.03 hrs.
Function group: 'ODBC API'
 Function: 'WindowFromDC'
6.38 hrs.Function: 'WSAGetLastError'
Function group: 'Windows Sockets 2 (Winsock)'
Google
Advertise here!