home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / dbmsg / sql / vbsql / adbsql.bas < prev    next >
Encoding:
BASIC Source File  |  1996-04-03  |  1.2 KB  |  49 lines

  1.  
  2. Function Logon% (pServer$, pLoginId$, pPassword$, pWorkSta$, pAppName$)
  3. '
  4. ' Open connection to SQL Server. Returns channel number
  5. ' to use in further communication with SQL Server through
  6. ' this channel.
  7. '
  8. ' This function can be called one or several times from
  9. ' each form.
  10.  
  11.     Logon% = SqlOpenConnection(pServer$, pLoginId$, pPassword$, pWorkSta$, pAppName$)
  12.  
  13. End Function
  14.  
  15. Function SQLComm% (pChannel%, pCmd$)
  16. '
  17. ' Generalized function to send SQL statements to SQL
  18. ' Server. If global variable ShowSql is set to True,
  19. ' the SQL statement is shown in a messagebox before
  20. ' it is sent to SQL Server
  21.  
  22. Dim Res%
  23.  
  24.     If ShowSql Then
  25.         MsgBox pCmd$
  26.     End If
  27.     Do
  28.         Res% = SqlCancel(pChannel%)
  29.         If Res% <> SUCCEED% Then
  30.             Exit Do
  31.         End If
  32.         Res% = SQLCmd(pChannel%, pCmd$)
  33.         If Res% <> SUCCEED% Then
  34.             Exit Do
  35.         End If
  36.         Res% = SqlExec(pChannel%)
  37.         If Res% <> SUCCEED% Then
  38.             Exit Do
  39.         End If
  40.         Res% = SqlResults%(pChannel%)
  41.         If Res% <> SUCCEED% Then
  42.             Exit Do
  43.         End If
  44.     Loop Until True
  45.     SQLComm% = Res%
  46.  
  47. End Function
  48.  
  49.