home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / windows / sqllink.zip / README.TXT < prev    next >
Text File  |  1990-08-09  |  52KB  |  1,841 lines

  1. SQLSoft
  2. 45 Front St. So., Suite B
  3. Issaquah, WA  98027
  4. (206)391-5099
  5.  
  6. SQL SoftLink is available for $149.95.
  7. Visa/Mastercard accepted as well as checks.
  8.  
  9.  
  10. SQL SOFTLINK
  11. USERS MANUAL
  12.  
  13.  
  14.  
  15.  
  16. INTRODUCTION
  17.  
  18. SQLSoft is a leader in the emerging world of client/server computing services for personal computer 
  19. networks.  Our mission is simple:
  20.  
  21.   "We weave networks and databases into cost-effective solutions".
  22.  
  23. SQL SoftLink is a utility designed to provide a link between most Windows 2.X and 3.0 applications 
  24. supporting DDE and Microsoft's OS/2-based SQL Server.
  25.  
  26. Many Windows applications exist today that support DDE.  Now, with SQL SoftLink running, users 
  27. and developers can access the power of the SQL Server relational database .
  28.  
  29. As systems integrators, we are willing to work with our customers in altering SQL SoftLink to 
  30. satisfy specific needs.  If you have a request for such a service don't hesitate to give us a call in 
  31. order to discuss what we can do for you.  Our number is (206)391-5099.
  32.  
  33.  
  34. What is SQL Server?
  35.  
  36. SQL Server is a high performance, multiuser relational database management system (RDBMS) 
  37. designed to support high-volume transaction processing - like on-line order entry - as well as less 
  38. demanding decision-support applications - like sales analysis - on PC-based LANs.
  39.  
  40. SQL Server employs advanced software technology that gives it reliability, performance, and data 
  41. processing capabilities equal to or better than those found in production-oriented, 
  42. minicomputer/mainframe-based database management systems (DBMSs).  Transaction processing 
  43. ensures that SQL Server databases are consistent and can be recovered in case of system failure - 
  44. whatever the cause.  Built-in data integrity logic provides a mechanism that enforces complex 
  45. relational controls within the database itself.  Critical business guidelines such as don't delete a 
  46. customer with open orders can be enforced easily across all applications and users.
  47.  
  48. High performance architecture makes optimum use of current-generation hardware, maintaining high 
  49. throughput levels as more users are added to the LAN.  And advanced administration and security 
  50. features ensure a secure, easy-to-manage system.  All this quality and all these features make true 
  51. production-oriented, mission-critical applications a reality on local area networks.
  52.  
  53. What is DB-LIBRARY?
  54.  
  55. SQL Server has an open (documented and published) Application Programming Interface (API) that 
  56. allows any software developer to build client-based (front-end) applications or even server-based 
  57. applications (back-end applications that include SQL Server itself) that work with SQL Server.
  58.  
  59. DB-LIBRARY is a set of C subroutines that gives application developers a standard way to interface 
  60. their applications with SQL Server.  DB-LIBRARY allows SQL commands to be incorporated into 
  61. an application, enabling the application to retrieve and update values from a database.
  62.  
  63. How does DB-LIBRARY access SQL Server?
  64.  
  65. DB-LIBRARY routines provide full access to all SQL Server capabilities through a consistent, easy-
  66. to-use API.  DB-LIBRARY subroutines are divided into the following categories:
  67.  
  68. *    Initialization routines allowing front-end applications to connect to a SQL Server or to 
  69. multiple SQL Servers 
  70.  
  71. *    Command set-up functions allowing the application to construct SQL queries in a 
  72. communications buffer and to send these queries over the network to SQL Server
  73.  
  74. *    Data retrieval and results processing functions giving front-end applications easy access to 
  75. the returned data
  76.  
  77. *    Close/cleanup routines closing the connection(s) to SQL Server and de-allocating 
  78. communications structures
  79.  
  80. *    Routines handling large text/images, browse, and the two-phase commit protocol for 
  81. distributed updates
  82.  
  83. *    Utility type procedures - datatype conversion, bulk copy, error and message handling, etc.
  84.  
  85. These LIBRARY routines can be used with C, COBOL, or other compilers that conform to Pascal 
  86. calling conventions.  DB-LIBRARY can be used with application programs royalty-free and comes in 
  87. separate versions for use with DOS-, OS/2- and Microsoft Windows-based client applications.  DB-
  88. LIBRARY is a static-link library under DOS, a Dynamic link Library under Windows, and a 
  89. Dynamic Link Library (DLL) under OS/2.
  90.  
  91. The transparent interface of DB-LIBRARY insulates the programmer from networking details and 
  92. server protocols.  This guarantees that an application will run even if the internal specifications of 
  93. SQL Server change.  System software updates won't disrupt the operation of workstation application 
  94. programs.  The approach taken by SQL Server with DB-LIBRARY has several advantages compared 
  95. to the embedded SQL host language interface used by other DBMSs.  Embedded SQL requires that 
  96. statements be precompiled before the entire application is compiled and linked.  Not so with DB-
  97. LIBRARY.
  98.  
  99. By avoiding the preprocessing step, writing applications for SQL Server is more straightforward and 
  100. efficient.  When debugging, the developer works with the original source code, not some intermediate 
  101. form.  Not precompiling also saves having to ship a BIND file (a hard-coded access plan associated 
  102. with each database) with an application.  In the future, DB-LIBRARY will also support precompiling 
  103. to facilitate the porting of mainframe applications to the PC environment, giving developers a choice 
  104. between the direct call-level interface and the precompiled approach.
  105.  
  106.  
  107. What is DDE?
  108.  
  109. Dynamic Data Exchange (DDE) is a protocol through which Windows applications can directly 
  110. communicate.  With the use of DDE, Windows applications are able to share information, resulting in 
  111. a more productive working environment.  The difference between DDE and the clipboard is that 
  112. DDE allows "real time data transfer," while the clipboard allows only for manual, one data transfer.  
  113. DDE allows these applications to "talk" to each other by establishing active links.  These links are 
  114. created when one application initiates a conversation to another application.  The application that 
  115. initiates the conversation is the "client" and the application that responds is the "server".  One 
  116. requirement of transferring data via DDE is that both applications must be running simultaneously.
  117.  
  118. Many applications utilize the DDE protocol by the use of statements in their macro languages, for 
  119. example Microsoft Excel and Microsoft Word for Windows.  Other applications such as 
  120. dBFast/Windows are development environments and the DDE statements are part of the procedural 
  121. code.
  122.  
  123. The basic DDE protocol consists of only nine messages, although each application is slightly different 
  124. in the way each of these messages are implemented.  Only four of these messages are used by the 
  125. client with SQL SoftLink.  These DDE messages are:
  126.  
  127.  
  128. INITIATE
  129. Initiates a DDE conversation between the client 
  130. and server applications.
  131.  
  132.  
  133. TERMINATE
  134. Terminates a DDE conversation.
  135.  
  136.  
  137. REQUEST
  138. DDE message requesting a one-time transfer of 
  139. data from the server.
  140.  
  141.  
  142. POKE
  143. DDE message used to send data to the server.
  144.  
  145.  
  146.  
  147. DDE Client-Server Diagram
  148.  
  149.  
  150.  
  151.  
  152. Items Poked To SQL SoftLink
  153. Server, UserName, Pswd, Dbase
  154. Xstr1, Xstr2....Xstr8
  155.  
  156. Functions Requested From SQL SoftLink
  157. Connect, SetOpt, Dbexit, Dbcmd, Dbsqlexec
  158. Dbcount, Dbconvert, Dbnextrow, Dbresults, Dbrows
  159. Getexcel, Txtdump, Row, Dbfreebuf, Fastins
  160. Msgmsg, Dblmsg, Sysmsg
  161.  
  162. What is SQL SoftLink?
  163.  
  164. SQL SoftLink is a Windows utility that runs behind other windows applications, such as Microsoft 
  165. Excel, Microsoft Word for Windows, and dBFast/Windows.  SQL SoftLink makes calls to SQL 
  166. Server using the DB-LIBRARY dynamic link library for windows.  Applications such as Excel can 
  167. receive data from SQL Server by sending DDE messages to SQL SoftLink which requests the 
  168. appropriate DB-LIBRARY calls.
  169.  
  170. The first step in making a call to SQL Server is to initiate a conversation between your application 
  171. and SQL SoftLink.  Next is to connect to SQL Server and use the correct database.  This is 
  172. accomplished by poking the information to SQL SoftLink and requesting the appropriate DB-
  173. LIBRARY statement.  Once connected to SQL Server the actual SQL statement can be poked to 
  174. SQL SoftLink.  The statement will be processed once the correct DB-LIBRARY statement is 
  175. requested from SQL SoftLink.  The final step is to request the data from SQL SoftLink.  Once the 
  176. data is in your application it can be formatted and maneuvered within the constraints of the particular 
  177. application.  After the user is finished accessing data from SQL Server, the conversation can be 
  178. terminated with the DDE terminate message.
  179.  
  180. Items in SQL SoftLink
  181.  
  182. There are 12 items or variables used while working with SQL SoftLink.  They are as follows:
  183.  
  184. ITEMS
  185.  
  186. Server
  187. The name of the server on which Microsoft 
  188. SQL Server resides.
  189.  
  190.  
  191. UserName
  192. The name of the user to be logged on to 
  193. Microsoft SQL Server.
  194.  
  195.  
  196. Pswd
  197. The password of the user to be logged on to 
  198. Microsoft SQL Server.
  199.  
  200.  
  201. Dbase
  202. The database to be used on Microsoft SQL 
  203. Server.
  204.  
  205.  
  206. Xstr1
  207. Variable used to pass parameters to SQL 
  208. SoftLink.
  209.  
  210.  
  211. Xstr2
  212. Variable used to pass parameters to SQL 
  213. SoftLink.
  214.  
  215.  
  216. Xstr3
  217. Variable used to pass parameters to SQL 
  218. SoftLink.
  219.  
  220.  
  221. Xstr4
  222. Variable used to pass parameters to SQL 
  223. SoftLink.
  224.  
  225.  
  226. Xstr5
  227. Variable used to pass parameters to SQL 
  228. SoftLink.
  229.  
  230.  
  231. Xstr6
  232. Variable used to pass parameters to SQL 
  233. SoftLink.
  234.  
  235.  
  236. Xstr7
  237. Variable used to pass parameters to SQL 
  238. SoftLink without losing the carriage return and 
  239. line feed.*
  240.  
  241.  
  242. Xstr8
  243. Variable used to pass parameters to SQL 
  244. SoftLink without losing the carriage return and 
  245. line feed.
  246.  
  247.  
  248.  
  249. In addition to the variables listed above, the topic that is called when initiating a conversation in SQL 
  250. SoftLink is "SQL".  A few of the SQL SoftLink functions require that parameters be passed to them 
  251. to define various items such as data types.  Hence, the reasoning for the Xstr1 through Xstr8 Items.
  252.  
  253. *NOTE:  Because Microsoft SQL Server does not need a carriage return and line feed, SQL 
  254. SoftLink filters these out when passed from a client application.  We recognize that there might be 
  255. some instances where a user will want to pass the carriage return and line feed.  As a result Xstr7 and 
  256. Xstr8 can be used to accomplish this task.  Xstr7 subtracts 20 from the ascii code of the character it 
  257. receives and copies this to Xstr8.  Therefore, if the user wishes to pass a carriage return to SQL 
  258. SoftLink he would pass the "!" which has an ascii code of 33.  Xstr7 subtracts 20 from this, which is 
  259. the carriage return (ascii code 13), and copies this to Xstr8.
  260.  
  261. Description of SQL SoftLink Functions
  262.  
  263. SQL SoftLink utilizes about 20 different DB-LIBRARY calls.  These calls are combined and used in 
  264. the 10 SQL SoftLink functions.  The following lists the functions and their uses.
  265.  
  266.  
  267. SQL Soft Link Functions
  268.  
  269. Connect
  270. Requests connection to SQL Server and to use a 
  271. particular database.  This function consists of 
  272. the following DB-LIBRARY calls.
  273. Dbclose, Dblogin, Dbsetluser, Dbsetlpwd, 
  274. Dbopen and Dbuse
  275.  
  276.  
  277. SetOpt
  278. Sets DB-LIBRARY options in SQL Server.  
  279. This function consists of the following DB-
  280. LIBRARY call.
  281. Dbsetopt
  282.  
  283.  
  284. Dbexit
  285. Disconnects from SQL Server.  This function 
  286. consists of the following DB-LIBRARY call.
  287. Dbexit
  288.  
  289.  
  290. Dbcmd
  291. Adds text to the input buffer.  This function 
  292. consists of the following DB-LIBRARY call.
  293. Dbcmd
  294.  
  295.  
  296. Dbsqlexec
  297. Sends the text stored in the input buffer to SQL 
  298. Server.  This function consists of the following 
  299. DB-LIBRARY call.
  300. Dbsqlexec
  301.  
  302.  
  303. Dbcount
  304. Returns the number of rows returned by the 
  305. SQL statement.  This function consists of the 
  306. following DB-LIBRARY call.
  307. Dbcount
  308.  
  309.  
  310. Dbconvert
  311. Returns and convert the data from SQL Server.  
  312. The data types supported are SQLCHAR, 
  313. SQLDATETIME, SQLFLT8, SQLINT1, 
  314. SQLINT2, SQLINT4, and SQLMONEY.  The 
  315. SQL SoftLink translations of these data types 
  316. are respectively CHAR, DATETIME, FLT8, 
  317. INT1, INT2, INT4, and MONEY.  This 
  318. function consists of the following DB-
  319. LIBRARY calls.
  320. Dbconvert, Dbdata, and Dbdatlen
  321.  
  322.  
  323. Dbnextrow
  324. Reads the next row of the query from SQL 
  325. Server.  This function consists of the following 
  326. DB-LIBRARY call.
  327. Dbnextrow
  328.  
  329.  
  330. Dbresults
  331. Sets up the results of the query.  This function 
  332. consists of the following DB-LIBRARY call.
  333. Dbresults
  334.  
  335.  
  336. Dbrows
  337. Determines whether the current SQL statement 
  338. actually returned rows.  This function consists of 
  339. the following DB-LIBRARY call.
  340. Dbrows
  341.  
  342.  
  343. Getexcel
  344. Establishes a DDE conversation between SQL 
  345. SoftLink and Microsoft Excel, where Excel acts 
  346. as the server and SQL SoftLink is the client.
  347.  
  348. Txtdump
  349. Sends entire results query to Microsoft Excel 
  350. from SQL SoftLink.
  351.  
  352. Row
  353. Returns a row of data from SQL SoftLink to 
  354. the client application.
  355.  
  356. Dbfreebuf
  357. Clears the Dbcmd buffer.
  358.  
  359. Fastins
  360. Inserts, updates, or deletes data on Microsoft 
  361. SQL Server.  Used when the user is not 
  362. expecting any data back from Microsoft SQL 
  363. Server.  
  364.  
  365. Msgmsg
  366. Returns DBLIB nonerror messages.
  367.  
  368. Dblmsg
  369. Returns DBLIB error messages.
  370.  
  371. Sysmsg
  372. Returns DOS error messages.
  373.  
  374.  
  375. SQL SoftLink Functions
  376.  
  377. Connect
  378.  
  379. Syntax:
  380. Connect
  381.  
  382.  
  383. Purpose:
  384. To log in to Microsoft SQL Server and to use a particular database
  385.  
  386.  
  387. Arguments:
  388. The server name, user name, password and database need to be poked to 
  389. SQL SoftLink before the Connect function can be requested.
  390.  
  391.  
  392. Returns:
  393. "F" -if the user did not get logged in.
  394. "T" -if the user did get logged in and established a process.
  395. "1" -if the user did not establish a process.
  396. "2" -if the user could not use the specific database.
  397.  
  398.  
  399. Example:
  400. DDEPoke Channum, "Server", Server$
  401. DDEPoke Channum, "UserName", Name$
  402. DDEPoke Channum, "Pswd", Password$
  403. DDEPoke Channum, "Dbase", Database$
  404. A$=DDERequest$(Channum, "Connect")
  405.  
  406.  
  407.  
  408.  
  409. SetOpt
  410.  
  411. Syntax:
  412. SetOpt
  413.  
  414.  
  415. Purpose:
  416. To set DB-LIBRARY options in SQL Server.
  417.  
  418.  
  419. Arguments:
  420. Two parameters need to be passed to SQL SoftLink before calling this 
  421. function.  They are the option and param arguments of the dbsetopt DB-
  422. LIBRARY function.  The user must pass the option parameter in Xstr1 
  423. and the param parameter in Xstr2.
  424.  
  425.  
  426. Returns:
  427. "T" -if the function is successful
  428. "F" -if the function is not successful
  429.  
  430.  
  431. Example:
  432. DDEPoke Channum, "Xstr1", "DBBUFFER"
  433. DDEPoke Channum, "Xstr2", "500"
  434. A$=DDERequest$(Channum, "SetOpt")
  435.  
  436.  
  437.  
  438.  
  439. Dbexit
  440.  
  441. Syntax:
  442. Dbexit
  443.  
  444.  
  445. Purpose:
  446. To disconnect from Microsoft SQL Server and close all open processes.
  447.  
  448.  
  449. Arguments:
  450. There are no arguments.
  451.  
  452.  
  453. Returns:
  454. There is no return value.
  455.  
  456.  
  457. Example:
  458. X$=DDERequest$(Channum, "Dbexit")
  459.  
  460.  
  461.  
  462.  
  463. Dbcmd
  464.  
  465. Syntax:
  466. Dbcmd
  467.  
  468.  
  469. Purpose:
  470. Adds text to the input buffer.
  471.  
  472.  
  473. Arguments:
  474. One parameter needs to be passed to this function before it is called.  The 
  475. user must use Xstr1 to pass this parameter.
  476.  
  477.  
  478. Returns:
  479. "T" -if successful.
  480. "F" -if unsuccessful.
  481.  
  482.  
  483. Example:
  484. DDEPoke Channum, "Xstr1", "select address, city, state, zip from authors"
  485. A$=DDERequest$(Channum, "Dbcmd")
  486.  
  487.  
  488.  
  489.  
  490. Dbsqlexec
  491.  
  492. Syntax:
  493. Dbsqlexec
  494.  
  495.  
  496. Purpose:
  497. Sends the text stored in the input buffer to Microsoft SQL Server.
  498.  
  499.  
  500. Arguments:
  501. There are no arguments.
  502.  
  503.  
  504. Returns:
  505. "T" -if successful
  506. "F" -if unsuccessful
  507.  
  508.  
  509. Example:
  510. B$=DDERequest$(Channum, "Dbsqlexec")
  511.  
  512.  
  513.  
  514.  
  515. Dbcount
  516.  
  517. Syntax:
  518. Dbcount
  519.  
  520.  
  521. Purpose:
  522. To determine the number of rows returned by the SQL statement.
  523.  
  524.  
  525. Arguments:
  526. There are no arguments.
  527.  
  528.  
  529. Returns:
  530. The number of rows affected in text format.
  531.  
  532.  
  533. Example:
  534. B$=DDERequest$(Channum, "Dbcount")
  535.  
  536.  
  537.  
  538.  
  539. Dbconvert
  540.  
  541. Syntax:
  542. Dbconvert
  543.  
  544.  
  545. Purpose:
  546. Returns and converts the data from Microsoft SQL Server.
  547.  
  548.  
  549. Arguments:
  550. Before calling Dbconvert, two parameters must be passed to it.  The first 
  551. is the number of the item in the SQL statement.  For example in the 
  552. following SQL statement, "Select address, city, state, zip.....",  address=1, 
  553. city=2, sate=3, etc.  The other parameter is the type of data that is being 
  554. returned.  The data types supported are SQLCHAR, SQLDATETIME, 
  555. SQLFLT8, SQLINT1, SQLINT2, SQLINT4, and SQLMONEY.  The 
  556. SQL SoftLink translations of these data types are respectively CHAR, 
  557. DATETIME, FLT8, INT1, INT2, INT4, and MONEY.
  558.  
  559.  
  560. Returns:
  561. One field of data returned from the requested query.
  562.  
  563.  
  564. Example:
  565. DDEPoke Channum, "Xstr1", "1"
  566. DDEPoke Channum, "Xstr2", "CHAR"
  567. addr$=DDERequest$(Channum, "Dbconvert")
  568.  
  569.  
  570.  
  571.  
  572. Dbnextrow
  573.  
  574. Syntax:
  575. Dbnextrow
  576.  
  577.  
  578. Purpose:
  579. Reads the next row of the query from Microsoft SQL Server.
  580.  
  581.  
  582. Arguments:
  583. There are no arguments.
  584.  
  585. Returns:
  586. One of five types of values:
  587. "-1" -if a regular row is read.
  588. "-2" -if there are no more rows to be read or the statement didn't return 
  589. any rows.
  590. "-3" -If buffering is turned on and reading the next row would cause the 
  591. buffer to be exceeded.
  592. "0" -if the function was unsuccessful.
  593.  
  594. If a compute row is read, the computeid of the row is returned.
  595.  
  596.  
  597. Example:
  598. D$=DDERequest$(Channum, "Dbnextrow")
  599.  
  600.  
  601.  
  602.  
  603. Dbresults
  604.  
  605. Syntax:
  606. Dbresults
  607.  
  608.  
  609. Purpose:
  610. Sets up the results of the previous or current query.
  611.  
  612.  
  613. Arguments:
  614. There are no arguments.
  615.  
  616.  
  617. Returns:
  618. One of three types of values:
  619. "1" -if successful
  620. "0" -if unsuccessful
  621. "2" -if there are no more results to be processed.
  622.  
  623.  
  624. Example:
  625. C$=DDERequest$(Channum, "Dbresults")
  626.  
  627.  
  628.  
  629.  
  630. Dbrows
  631.  
  632. Syntax:
  633. Dbrows
  634.  
  635.  
  636. Purpose:
  637. To determine whether the current SQL statement actually returned rows.
  638.  
  639.  
  640. Arguments:
  641. There are no arguments.
  642.  
  643.  
  644. Returns:
  645. "1" -if successful
  646. "0" -if unsuccessful
  647.  
  648.  
  649. Example:
  650. D$=DDERequest$(Channum, "Dbrows")
  651.  
  652.  
  653.  
  654.  
  655. Getexcel
  656.  
  657. Syntax:
  658. Getexcel
  659.  
  660.  
  661. Purpose:
  662. To establish a DDE conversation between SQL SoftLink and Microsoft 
  663. Excel, where Excel acts as the server and SQL SoftLink is the client.
  664.  
  665.  
  666. Arguments:
  667. One parameter must be passed to SQL SoftLink using Xstr1 before this 
  668. function can be called.  the parameter is the active worksheet and cell.  
  669. The active cell must be sent in R1C1 format.  This can be accomplished 
  670. using the Selection() function in the Excel macro language.
  671.  
  672.  
  673. Returns:
  674. There is no return.
  675.  
  676.  
  677. Example:
  678. =SELECTION()
  679. =REFTEXT(SELECTION())
  680. =FORMULA(A57,B58)
  681. =POKE(A4,"Xstr1",B58)
  682. =REQUEST(A4,"Getexcel")
  683.  
  684.  
  685.  
  686.  
  687. Txtdump
  688.  
  689. Syntax:
  690. Txtdump
  691.  
  692.  
  693. Purpose:
  694. To return data from Microsoft SQL Server.
  695.  
  696. Arguments:
  697. There are no arguments, although this function must be called after 
  698. calling the Getexcel function.
  699.  
  700.  
  701. Returns:
  702. Returns entire query at once from Microsoft SQL Server.
  703.  
  704.  
  705. Example:
  706. =REQUEST(A4,"Getexcel")
  707. =REQUEST(A4,"Txtdump")
  708.  
  709.  
  710.  
  711.  
  712. Row
  713.  
  714. Syntax:
  715. Row
  716.  
  717.  
  718. Purpose:
  719. To return data from Microsoft SQL Server without having to worry 
  720. about the data types.
  721.  
  722.  
  723. Arguments:
  724. There are no arguments.
  725.  
  726.  
  727. Returns:
  728. Returns a row at a time from the query to Microsoft SQL Server.  The 
  729. format of the row is a text string with the columns separated with a tab 
  730. and a carriage return and line feed at the end of each row.  After the last 
  731. row is returned, SQL SoftLink returns a character string 9, which is end 
  732. of file.
  733.  
  734.  
  735. Example:
  736. While title$ <> Chr$(26)
  737.   title$ = DDERequest$(Channum, "Row")
  738. Wend
  739.  
  740.  
  741.  
  742.  
  743. Dbfreebuf
  744.  
  745. Syntax:
  746. Dbfreebuf
  747.  
  748.  
  749. Purpose:
  750. To clear the Dbcmd buffer.
  751.  
  752.  
  753. Arguments:
  754. There are no arguments.
  755.  
  756.  
  757. Returns:
  758. "T" -if successful
  759.  
  760.  
  761. Example:
  762. =REQUEST(A4,"Dbfreebuf")
  763.  
  764.  
  765.  
  766.  
  767. Fastins
  768.  
  769. Syntax:
  770. Fastins
  771.  
  772.  
  773. Purpose:
  774. Inserts, updates, or deletes data on Microsoft SQL Server.  Used when 
  775. the user is not expecting any data back from Microsoft SQL Server.
  776.  
  777.  
  778. Arguments:
  779. Before Fastins is called, the user must pass a one line SQL statement to 
  780. SQL SoftLink with the Xstr1 parameter.
  781.  
  782.  
  783. Returns:
  784. "T" -if successful
  785. "F" -if unsuccessful
  786.  
  787.  
  788. Example:
  789. DDEPoke Channum, "Xstr1", "Update authors set au_lname = 
  790. 'MacBadden' where au_lname = 'McBadden'"
  791. X$=DDERequest$(Channum, "Fastins")
  792.  
  793.  
  794.  
  795.  
  796. Msgmsg
  797.  
  798. Syntax:
  799. Msgmsg
  800.  
  801.  
  802. Purpose:
  803. To return DB-LIBRARY non-error messages.
  804.  
  805.  
  806. Arguments:
  807. There are no arguments.  This will also reset the message buffer once the 
  808. function has been called.
  809.  
  810.  
  811. Returns:
  812. DB-LIBRARY non-error messages.
  813.  
  814.  
  815. Example:
  816. M$=DDERequest$(Channum, "Msgmsg")
  817.  
  818.  
  819.  
  820.  
  821. Dblmsg
  822.  
  823. Syntax:
  824. Dblmsg
  825.  
  826.  
  827. Purpose:
  828. To return DB-LIBRARY error messages.
  829.  
  830.  
  831. Arguments:
  832. There are no arguments  This will also reset the message buffer once the 
  833. function has been called.
  834.  
  835.  
  836. Returns:
  837. DB-LIBRARY error messages.
  838.  
  839.  
  840. Example:
  841. M$=DDERequest$(Channum, "Dblmsg")
  842.  
  843.  
  844.  
  845.  
  846. Sysmsg
  847.  
  848. Syntax:
  849. Sysmsg
  850.  
  851.  
  852. Purpose:
  853. To return DOS error messages.
  854.  
  855.  
  856. Arguments:
  857. There are no arguments  This will also reset the message buffer once the 
  858. function has been called.
  859.  
  860.  
  861. Returns:
  862. DOS error messages.
  863.  
  864.  
  865. Example:
  866. M$=DDERequest$(Channum, "Sysmsg")
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873. Client Requirements
  874.  
  875. The requirements of the client consist of the following.
  876.  
  877. 386, 386sx or 286 PC set up as a DOS workstation.
  878. Microsoft Windows 286 ,386 or Windows 3.0
  879. Microsoft Lan Manager 1.1 or equivalent.
  880. Windows front end with DDE capabilities (Microsoft Word for Windows, Microsoft Excel or 
  881. dBFast/Windows.)
  882. 1 Mb RAM
  883. Suggested:
  884. 386 to the Max memory manager or Qemm.
  885. 2 Mb RAM or more.
  886.  
  887. In addition, when running SQL SoftLink under Windows 2.x, the following files are necessary, and 
  888. should be either in the working directory or in the path.
  889.  
  890. WIN87EM.EXE
  891. DBLIBW.EXE
  892.  
  893. If running SQL SoftLink under Windows 3.0, the following files need to be in either the working 
  894. directory or in the path.
  895.  
  896. DBNMP3.DLL
  897. W3DBLIB.DLL
  898. WIN87EM.DLL
  899.  
  900. All of the files listed above should be found in the following software packages.
  901.  
  902. Microsoft Windows 286, 386 or 3.0
  903. Microsoft LAN Manager or equivalent
  904. Microsoft SQL Server
  905.  
  906. Server Requirements
  907.  
  908. The requirements of the server consist of the following.
  909.  
  910. 386 or 386sx PC set up as a server.
  911. OS/2 1.1
  912. Microsoft Lan Manager 1.1 or equivalent.
  913. Microsoft SQL Server 1.0
  914. 8 Mb RAM
  915. Suggested:
  916. 10 Mb RAM or more
  917.  
  918.  
  919. Potential Memory Constraints
  920.  
  921. In the Microsoft Windows 2.x environment memory considerations can be quite a headache.  A 
  922. suggestion we have is to have at least 2 Mb of RAM and take advantage of a memory manager such 
  923. as 386 To The Max.  Here at SQLSoft have spent a great deal of time fine tuning our workstations 
  924. and have found it extremely rewarding.  For example on a 386 DOS Workstation running 3+Open 
  925. 1.1 with 4 Mb of RAM we are able to get 598k of free memory and after starting Microsoft Windows 
  926. we have about 430k of conventional memory.  We offer support on these memory issues to all 
  927. registered users of SQL SoftLink.  To register please see the registration section.
  928.  
  929.  
  930. Installation of EXE files
  931.  
  932. Installation of sample macros
  933.  
  934. SQL SOFTLINK AND MICROSOFT WORD FOR WINDOWS
  935.  
  936. The Microsoft Word For Windows macro language, WordBasic is used to send and receive the DDE 
  937. messages.  WordBasic is very similar to the Basic programming language, therefore an understanding 
  938. of the Basic language is helpful in writing macros in WordBasic.  In addition to most of the Basic 
  939. language, WordBasic has added many Word for Windows functions as well as the DDE messages 
  940. needed to have a conversation with SQL SoftLink and access SQL Server.
  941.  
  942. DDE Statements
  943.  
  944. The DDE statements used by WordBasic are as follows.
  945.  
  946. DDEInitiate()
  947. Syntax:  Channum=DDEInitiate(App$, Topic$)
  948.  
  949. Channum is a variable which represents the DDE Channel between Word for windows and 
  950. SQL SoftLink.  This is the channel over which the DDE conversation will take place.  App$ 
  951. is the name of the other application.  Topic$ is the name of something being accessed in the 
  952. other application.  In the case of SQL SoftLink the topic is "SQL".
  953.  
  954. Example:
  955.  
  956. Channum=DDEInitiate("SQL_SoftLink", "SQL")
  957.  
  958. This establishes a link between Microsoft Word for Windows and SQL SoftLink.
  959.  
  960. DDEPoke
  961. Syntax:  DDEPoke Channum, Item$, Data$
  962.  
  963. Channum refers to the channel established by DDEInitiate.  DDEPoke sends the string 
  964. defined by Data$ to the item in SQL SoftLink specified in Item$.
  965.  
  966. Example:
  967.  
  968. DDEPoke Channum, "Username", Name$
  969.  
  970. This sends the username specified by Name$ to the item in SQL SoftLink defined as 
  971. "Username."
  972.  
  973. DDERequest$()
  974. Syntax:  A$=DDERequest$(Channum, Item$)
  975.  
  976. Channum refers to the channel established by DDEInitiate.  DDERequest$() requests the 
  977. item in SQL SoftLink specified by Item$.
  978.  
  979. Example:
  980.  
  981. A$=DDERequest$(Channum, "Connect")
  982.  
  983. This requests that SQL SoftLink perform the "Connect" function.
  984.  
  985. DDETerminate
  986. Syntax:  DDETerminate Channum
  987.  
  988. Channum refers to the channel established by DDEInitiate.
  989.  
  990. Example:
  991.  
  992. DDETerminate Channum
  993.  
  994. This terminates the link between Microsoft Word for Windows and SQL SoftLink.
  995.  
  996. How to Implement
  997.  
  998. In order to access Microsoft SQL Server from Microsoft Word for Windows through SQL SoftLink, 
  999. the first thing needed is to make sure that both Microsoft Word for Windows and SQL SoftLink are 
  1000. up and running (SQL SoftLink may be iconized.)  In addition, Microsoft SQL Server must be running 
  1001. on a server on the network.
  1002.  
  1003. To establish a DDE link between Microsoft Word for Windows and SQL SoftLink a macro needs to 
  1004. be written in WordBasic.
  1005.  
  1006. The first part of the macro initiates the DDE channel between the two applications.  This is 
  1007. performed with the DDEInitiate statement.  For example:
  1008.  
  1009. Channum= DDEInitiate("SQL_SoftLink", "SQL")
  1010.  
  1011. In order to connect to Microsoft SQL Server the server name, username, password and database 
  1012. need to be poked to SQL SoftLink.  Once this is accomplished a request needs to be sent to SQL 
  1013. SoftLink asking for the "Connect" function.  For example:
  1014.  
  1015. DDEPoke Channum, "Server", Server$
  1016. DDEPoke Channum, "UserName", Name$
  1017. DDEPoke Channum, "Pswd", Password$
  1018. DDEPoke Channum, "Dbase", Database$
  1019. A$=DDERequest$(Channum, "Connect")
  1020.  
  1021. After these functions have been accomplished, there should be a connection between Microsoft Word 
  1022. for Windows and Microsoft SQL Server through SQL SoftLink.  Now SQL statements can be passed 
  1023. to SQL SoftLink in order to receive queries from Microsoft SQL Server.  For example:
  1024.  
  1025. DDEPoke Channum, "Xstr1", "select address, city, state, zip from authors"
  1026.  
  1027. Next is to place this SQL statement in a buffer.  For example:
  1028.  
  1029. A$=DDERequest$(Channum, "Dbcmd")
  1030.  
  1031. Additions to the SQL statement can be made by poking the information in the same manner as above 
  1032. and then requesting "Dbcmd."  Once the entire SQL statement is in the buffer, a series of SQL 
  1033. SoftLink functions need to be requested in order to execute the query.  The order of these is as 
  1034. follows.
  1035.  
  1036. B$=DDERequest$(Channum, "Dbsqlexec")
  1037. C$=DDERequest$(Channum, "Dbresults")
  1038. D$=DDERequest$(Channum, "Dbrows")
  1039.  
  1040. Depending on the number of rows returned, a loop may be set up for the next section.  This next 
  1041. section retrieves the data obtained in the query.  First, a row of data needs to be read. For example:
  1042.  
  1043. D$=DDERequest$(Channum, "Dbnextrow")
  1044.  
  1045. Next, the data needs to be returned and converted.  This can be accomplished one of two ways; 
  1046. through the use of the Dbconvert or Row functions in SQL SoftLink.
  1047.  
  1048. Before calling Dbconvert, two parameters must be passed to it.  The first is the number of the item in 
  1049. the SQL statement.  For example in the SQL statement above:  address=1, city=2, sate=3, etc.  The 
  1050. other parameter is the type of data that is being returned.  For example:
  1051.  
  1052. DDEPoke Channum, "Xstr1", "1"
  1053. DDEPoke Channum, "Xstr2", "CHAR"
  1054. addr$=DDERequest$(Channum, "Dbconvert")
  1055. DDEPoke Channum, "Xstr1", "2"
  1056. DDEPoke Channum, "Xstr2", "CHAR"
  1057. city$=DDERequest$(Channum, "Dbconvert")
  1058. DDEPoke Channum, "Xstr1", "3"
  1059. DDEPoke Channum, "Xstr2", "CHAR"
  1060. state$=DDERequest$(Channum, "Dbconvert")
  1061. (etc.)
  1062.  
  1063. With the use of the Row function, there is no need to pass the data type to SQL SoftLink.  The types 
  1064. of data are determined within SQL SoftLink.  Therefore all that is needed is to set up a loop that 
  1065. requests the Row function.  For example:
  1066.  
  1067. While title$ <> Chr$(26)
  1068.   title$ = DDERequest$(Channum, "Row")
  1069. Wend
  1070.  
  1071. The data returned can now be formatted and manipulated with other WordBasic functions.
  1072.  
  1073. Once all work with Microsoft SQL Server is completed it is best to terminate the link.  First the 
  1074. connection to Microsoft SQL Server must be terminated and then terminate the DDE link between 
  1075. Microsoft Word for Windows and SQL SoftLink.  For example:
  1076.  
  1077. X$=DDERequest$(Channum, "Dbexit")
  1078. DDETerminate Channum
  1079.  
  1080. Sample Macros
  1081.  
  1082. The following macros are a demonstration of Microsoft Word for Windows accessing data from 
  1083. Microsoft SQL Server.   They can be found by running the "normal.dot" file found on the diskette.
  1084.  
  1085. The first macro displays a dialog box requesting the server, username, password and database.  It 
  1086. then passes these parameters to SQL SoftLink and attempts to connect to Microsoft SQL Server.
  1087.  
  1088. Dim Shared Channum
  1089. Sub MAIN
  1090. Begin Dialog UserDialog 300, 125
  1091.   OKButton 200, 6, 64, 18
  1092.   CancelButton 200, 32, 64, 18
  1093.   Text 8, 10, 52, 12, "&Server"
  1094.   TextBox 75, 8, 106, 18, .TB1
  1095.   Text 8, 40, 42, 12, "&Name"
  1096.   TextBox 75, 38, 106, 18, .TB2
  1097.   Text 8, 70, 82, 12, "&Password"
  1098.   TextBox 75, 68, 106, 18, .TB3
  1099.   Text 8, 100, 82, 12, "&Database"
  1100.   TextBox 75, 98, 106, 18, .TB4
  1101. End Dialog
  1102. Dim dlg As Dialog UserDialog
  1103. dlg.TB1 = "CEO"
  1104. dlg.TB2 = "SA"
  1105. dlg.TB3 = ""
  1106. dlg.TB4 = "PUBS"
  1107. GetCurValues dlg
  1108. Dialog dlg
  1109. Server$ = dlg.TB1
  1110. Name$ = dlg.TB2
  1111. Password$ = dlg.TB3
  1112. Database$ = dlg.TB4
  1113. Print Server$, Name$, Password$, Database$
  1114.   Channum = DDEInitiate("SQL_SoftLink", "SQL")
  1115.   DDEPoke Channum, "Server", Server$
  1116.   DDEPoke Channum, "Username", Name$
  1117.   DDEPoke Channum, "Pswd", Password$
  1118.   DDEPoke Channum, "Dbase", Database$
  1119.   A$ = DDERequest$(Channum, "Connect")
  1120.   Print A$
  1121.   SetGlossary Channel$, Str$(Channum), 0
  1122. End Sub
  1123.  
  1124. This macro logs off of Microsoft SQL Server as well as terminates the DDE link between  Microsoft 
  1125. Word for Windows and SQL SoftLink.
  1126.  
  1127. Sub MAIN
  1128. C$ = GetGlossary$(Channel$, 0)
  1129. Channum = Val(C$)
  1130. If MsgBox("Terminate SQLLink?", 33) Then
  1131.     x$ = DDERequest$(Channum, "Dbexit")
  1132.     DDETerminate Channum
  1133.     MsgBox "SQLLink Terminated.", "", 0
  1134. End If
  1135. End Sub
  1136.  
  1137. The macro listed below requests the name of an author in the pubs database and then queries the 
  1138. database for that author's address.  In addition, it takes advantage of the Row function in order to 
  1139. retrieve all of the titles and year to date sales for the requested author.
  1140.  
  1141. Sub MAIN
  1142.   C$ = GetGlossary$(Channel$, 0)
  1143.   Channum = Val(C$)
  1144.   addr$ = " "
  1145.   city$ = " "
  1146.   state$ = " "
  1147.   zip$ = " "  
  1148.   Prompt$ = "Input Author's First Name."
  1149.   Fname$ = InputBox$(Prompt$)
  1150.   Prompt$ = "Input Author's Last Name."
  1151.   Lname$ = InputBox$(Prompt$)
  1152.   DDEPoke Channum, "Xstr1", "select address, city, state, zip from authors"
  1153.   A1$ = DDERequest$(Channum, "Dbcmd")
  1154.   DDEPoke Channum, "Xstr1", " where au_lname=" + "'" + Lname$ + "'" + " and au_fname=" + "'" 
  1155. + fname$ + "'"
  1156.   A$ = DDERequest$(Channum, "Dbcmd")
  1157.   B$ = DDERequest$(Channum, "Dbsqlexec")
  1158.   C$ = DDERequest$(Channum, "Dbresults")
  1159.   dbr$ = DDERequest$(Channum, "Dbrows")
  1160.   If dbr$ = "0" Then
  1161.     MsgBox "Author Not Found.", "Error", 0
  1162.     Goto Quitx :
  1163.   End If
  1164.   D$ = DDERequest$(Channum, "Dbnextrow")
  1165.   DDEPoke Channum, "Xstr1", "1"
  1166.   DDEPoke Channum, "Xstr2", "CHAR"
  1167.   addr$ = DDERequest$(Channum, "Dbconvert")
  1168.   DDEPoke Channum, "Xstr1", "2"
  1169.   DDEPoke Channum, "Xstr2", "CHAR"
  1170.   city$ = DDERequest$(Channum, "Dbconvert")
  1171.   DDEPoke Channum, "Xstr1", "3"
  1172.   DDEPoke Channum, "Xstr2", "CHAR"
  1173.   state$ = DDERequest$(Channum, "Dbconvert")
  1174.   DDEPoke Channum, "Xstr1", "4"
  1175.   DDEPoke Channum, "Xstr2", "CHAR"
  1176.   zip$ = DDERequest$(Channum, "Dbconvert")
  1177.   Insert Fname$ + " " + Lname$
  1178.   LineDown
  1179.   Insert addr$
  1180.   LineDown
  1181.   Insert City$ + ", " + State$ + "  " + Zip$
  1182.   LineDown
  1183.   LineDown
  1184.   HLine 4
  1185.   Insert " " + Fname$ + ","
  1186.   E$ = DDERequest$(Channum, "Dbnextrow")
  1187.   LineDown
  1188.   LineDown
  1189.   LineDown
  1190.   LineDown
  1191.   LineDown
  1192.   LineDown
  1193.   LineDown
  1194.   DDEPoke Channum, "Xstr1", "select t1.title, t1.ytd_sales"
  1195.   A1$ = DDERequest$(Channum, "Dbcmd")
  1196.   DDEPoke Channum, "Xstr1", " from titles t1, authors t2, titleauthor t3"
  1197.   A1$ = DDERequest$(Channum, "Dbcmd")
  1198.   DDEPoke Channum, "Xstr1", " where (t2.au_id=t3.au_id) and (t3.title_id=t1.title_id) and"
  1199.   A1$ = DDERequest$(Channum, "Dbcmd")
  1200.   DDEPoke Channum, "Xstr1", " t2.au_fname = " + "'" + Fname$ + "'" + " and t2.au_lname=" + "'" 
  1201. + Lname$ + "'"
  1202.   A1$ = DDERequest$(Channum, "Dbcmd")
  1203.   B$ = DDERequest$(Channum, "Dbsqlexec")
  1204.   C$ = DDERequest$(Channum, "Dbresults")
  1205.   dbr$ = DDERequest$(Channum, "Dbrows")
  1206.   title$ = " "
  1207.   While title$ <> Chr$(26)
  1208.   title$ = DDERequest$(Channum, "Row")
  1209.   If title$ = Chr$(26) Then
  1210.     Goto Quitx :
  1211.   End If
  1212.   Insert title$
  1213.   LineDown
  1214.   Wend
  1215. Quitx:  
  1216.   If MsgBox("Terminate SQLLink?", 33) Then
  1217.     x$ = DDERequest$(Channum, "Dbexit")
  1218.     Print x$
  1219.     DDETerminate Channum
  1220.     MsgBox "SQLLink Terminated.", "", 0
  1221.   End If
  1222. End Sub
  1223.  
  1224.  
  1225. SQL SOFTLINK AND MICROSOFT EXCEL
  1226.  
  1227. The Microsoft Excel Macro Language is used to send and receive the DDE messages.  The Macro 
  1228. Language contains the necessary DDE statements required to have a conversation between Microsoft 
  1229. Excel and SQL SoftLink.
  1230.  
  1231. DDE Statements
  1232.  
  1233. The DDE Statements used in the Microsoft Excel Macro Language
  1234. are as follows:
  1235.  
  1236. Initiate()
  1237. Syntax: =Initiate(App$, Topic$)
  1238.  
  1239. The Initiate() command creates a DDE Channel between Microsoft Excel and SQL 
  1240. SoftLink.  This is the channel over which the DDE conversation will take place.  App$ is the 
  1241. name of the other application.  Topic$ is the name of something being accessed in the other 
  1242. application.  In the case of SQL SoftLink the Topic$ is "SQL".
  1243.  
  1244. Example:
  1245.  
  1246. =Initiate("SQL_SoftLink", "SQL")
  1247.  
  1248. This establishes a link between Microsoft Excel and SQL SoftLink.
  1249.  
  1250. Poke()
  1251. Syntax: =Poke(Channum, Item$, Data)
  1252.  
  1253. Channum refers to the channel established by Initiate().  Poke sends the string defined by 
  1254. Data to the item in SQL SoftLink specified in Item$.
  1255.  
  1256. Example:
  1257.  
  1258. =Poke(A4,"UserName",I19)
  1259.  
  1260. This sends the username defined by cell I19 to the item in SQL SoftLink defined as 
  1261. "UserName" across the channel defined in cell A4 by the Initiate statement.
  1262.  
  1263. Request()
  1264. Syntax: =Request(Channum, Item)
  1265.  
  1266. Channum refers to the channel established by Initiate().  Request() requests the item in SQL 
  1267. SoftLink specified by Item.
  1268.  
  1269. Example:
  1270.  
  1271. =Request(A4, "Connect")
  1272.  
  1273. This requests that SQL SoftLink perform the "Connect" function across the DDE channel 
  1274. defined in cell A4 by the Initiate() statement.
  1275.  
  1276. Terminate(Channum)
  1277. Syntax:  Terminate(Channum)
  1278.  
  1279. Channum refers to the channel established by DDEInitiate.
  1280.  
  1281. Example:
  1282.  
  1283. Terminate(A4)
  1284.  
  1285. This terminates the link between Microsoft Word for Windows and SQL SoftLink that was 
  1286. created by the Initiate() statement in cell A4.
  1287.  
  1288. How to Implement
  1289.  
  1290. In order to access Microsoft SQL Server from Microsoft Excel through SQL SoftLink, the first thing 
  1291. needed is to make sure that both Microsoft Excel and SQL SoftLink are up and running (SQL 
  1292. SoftLink may be iconized.)  In addition, Microsoft SQL Server must be running on a server on the 
  1293. network.
  1294.  
  1295. To establish a DDE link between Microsoft Excel and SQL SoftLink a macro needs to be written in 
  1296. the Microsoft Excel Macro Language.
  1297.  
  1298. The first part of the macro initiates the DDE channel between the two applications.  This is 
  1299. performed with the Initiate statement.  For example:
  1300.  
  1301. =Initiate("SQL_SoftLink", "SQL")
  1302.  
  1303. In order to connect to Microsoft SQL Server the server name, username, password and database 
  1304. need to be poked to SQL SoftLink.  Once this is accomplished a request needs to be sent to SQL 
  1305. SoftLink asking for the "Connect" function.  For example:
  1306.  
  1307. =Poke(A4,"Server",I17)
  1308. =Poke(A4,"UserName",I19)
  1309. =Poke(A4,"Pswd",I21)
  1310. =Poke(A4,"Dbase",I23)
  1311. =Request(A4,"Connect")
  1312.  
  1313. A4=cell location of Channum
  1314. I17, I19, I21, I23 are cell
  1315. locations of Servername,
  1316. Username, Password, and
  1317. Database respectively.
  1318.  
  1319.  
  1320.  
  1321.  
  1322. After these functions have been accomplished, there should be a connection between Microsoft Excel 
  1323. and Microsoft SQL Server through SQL SoftLink.  Now SQL statements can be passed to SQL 
  1324. SoftLink in order to receive queries from Microsoft SQL Server.  For example:
  1325.  
  1326. Cell Location
  1327.  
  1328. A33
  1329.  
  1330. A34
  1331. A35
  1332.  
  1333. Macro Statements
  1334.  
  1335. ="select address, city, state, zip from authors"
  1336. =Formula(A33,B32)
  1337. =Poke(A4,"Xstr1",B32)
  1338.  
  1339.  
  1340.  
  1341. The Formula() function is necessary to place the SQL statement literally in a cell.  The poke 
  1342. statement then sends the SQL statement to SQL SoftLink.
  1343.  
  1344. Next is to place this SQL statement in a buffer.  For example:
  1345.  
  1346. Cell Location
  1347.  
  1348. A36
  1349.  
  1350. Macro Statements
  1351.  
  1352. =Request(A4,"Dbcmd")
  1353.  
  1354.  
  1355.  
  1356. Additions to the SQL statement can be made by poking the information in the same manner as above 
  1357. and then requesting "Dbcmd."  Once the entire SQL statement is in the buffer, a series of SQL 
  1358. SoftLink functions need to be requested in order to execute the query.  The order of these is as 
  1359. follows.
  1360.  
  1361. Cell Location
  1362.  
  1363. A49
  1364. A50
  1365. A51
  1366.  
  1367. Macro Statements
  1368.  
  1369. =Request(A4,"Dbsqlexec")
  1370. =Request(A4,"Dbresults")
  1371. =Request(A4,"Dbrows")
  1372.  
  1373.  
  1374.  
  1375.  
  1376. Next, the data needs to be returned and converted.  There are two ways to receive this data.  The 
  1377. first is much faster than the second, although both will accomplish the same task.  This first method 
  1378. consists of the use of the Getexcel and Txtdump functions.  Instead of having to convert all the data 
  1379. using Dbconvert, it is possible to have SQL SoftLink perform this task.  In order to use these 
  1380. functions it is required that the active cell be poked to SQL SoftLink.  This can be accomplished with 
  1381. the following Excel macro functions.
  1382.  
  1383. =SELECTION()
  1384. =REFTEXT(SELECTION())
  1385. =FORMULA(A57,B58)
  1386. =POKE(A4,"Xstr1",B58)
  1387.  
  1388. Once this information has been transferred to SQL SoftLink the Getexcel and Txtdump functions can 
  1389. be requested.  The results will be sent back to Excel starting at the location of the active cell.
  1390.  
  1391. =REQUEST(A4,"Getexcel")
  1392. =REQUEST(A4,"Txtdump")
  1393.  
  1394.  
  1395.  
  1396. The second method is much, much slower.  It is implemented in the following way.
  1397.  
  1398. Depending on the number of rows returned, a loop may be set up for the next section.  This next 
  1399. section retrieves the data obtained in the query.  First, a row of data needs to be read.  For example:
  1400.  
  1401. Cell Location
  1402.  
  1403. A55
  1404.  
  1405. Macro Statements
  1406.  
  1407. =Request(A4,"Dbnextrow")
  1408.  
  1409.  
  1410.  
  1411.   This is done by calling the Dbconvert function in SQL SoftLink.  Before this function can be called, 
  1412. two parameters must be passed to it.  The first is the number of the item in the SQL statement.  For 
  1413. example in the SQL statement above:  address=1, city=2, state=3, etc.  The other parameter is the 
  1414. type of data that is being returned.  For example:
  1415.  
  1416. Cell Location
  1417.  
  1418. A57
  1419. Macro Statements
  1420.  
  1421. 1
  1422.  
  1423. A58
  1424. =Poke(A4,"Xstr1",A57)
  1425.  
  1426. A59
  1427. CHAR
  1428.  
  1429. A60
  1430. =Poke(A4,"Xstr2",A59)
  1431.  
  1432. A61
  1433. =Request(A4,"Dbconvert)
  1434.  
  1435. A62
  1436. 2
  1437.  
  1438. A63
  1439. =Poke(A4,"Xstr1",A62)
  1440.  
  1441. A64
  1442. CHAR
  1443.  
  1444. A65
  1445. =Poke(A4,"Xstr1",A67)
  1446.  
  1447. A66
  1448. =Poke(A4,"Xstr2",A64)
  1449.  
  1450. A67
  1451. =Request(A4,"Dbconvert)
  1452.  
  1453. A68
  1454. 3
  1455.  
  1456. A69
  1457. CHAR
  1458.  
  1459. A70
  1460. =Poke(A4,"Xstr2",A69)
  1461.  
  1462. A71
  1463. =Request(A4,"Dbconvert)
  1464.  
  1465.  
  1466. (etc.)
  1467.  
  1468.  
  1469. Cell A61 contains the address.
  1470. Cell A66 contains the city.
  1471. Cell A71 contains the state.
  1472.  
  1473. The data returned can now be formatted and manipulated with other Microsoft Excel Macro 
  1474. Language functions.
  1475.  
  1476. Once all work with Microsoft SQL Server is completed it is best to terminate the link.  First the 
  1477. connection to Microsoft SQL Server must be terminated and then terminate the DDE link between 
  1478. Microsoft Excel and SQL SoftLink.  For example:
  1479.  
  1480. =Request(A4,"Dbexit")
  1481. =Terminate(A4)
  1482.  
  1483. Sample Macros
  1484.  
  1485. The following macros are the same macros found on the supplied diskette.
  1486.  
  1487. The first macro is an example of a connection to Microsoft SQL Server.
  1488.  
  1489. A2    SQL.Connect
  1490. A3    =WORKSPACE(,,,,,,,FALSE)
  1491. A4    =INITIATE("SQL_SoftLink","SQL")
  1492. A5    =DIALOG.BOX(C13:I23)
  1493. A6    =IF(A5=FALSE,GOTO(A13))
  1494. A7    =POKE(A4,"Server",I17)
  1495. A8    =POKE(A4,"UserName",I19)
  1496. A9    =POKE(A4,"Pswd",I21)
  1497. A10    =POKE(A4,"Dbase",I23)
  1498. A11    =REQUEST(A4,"Connect")
  1499. A12    =IF(A10="T",ALERT("Connected to SQLServer",2),ALERT("Not Connected to 
  1500.     SQLServer",2))
  1501. A13    =RETURN()
  1502.  
  1503. This macro is an example of a disconnection from Microsoft SQL Server.
  1504.  
  1505. A16    SQL.Disconnect
  1506. A17    =ALERT("Terminate SQLServer Connection?",1)
  1507. A18    =A17
  1508. A19    =IF(A17=TRUE,GOTO(A20),GOTO(A23))
  1509. A20    =REQUEST(A4,"Dbexit")
  1510. A21    =TERMINATE(A4)
  1511. A22    =ALERT("SQLServer Connection Terminated",2)
  1512. A23    =RETURN()
  1513.  
  1514. The following macro is an example of a query to Microsoft SQL Server and takes advantage of the 
  1515. Getexcel and Txtdump functions.
  1516.  
  1517. A31    SQL.Query
  1518. A32    ="select t1.Au_fname,t1.au_lname, t3.title,t3.price"
  1519. A33    =FORMULA(A32,B32)
  1520. A34    =POKE(A4,"Xstr1",B32)
  1521. A35    =REQUEST(A4,"Dbcmd")
  1522. A36    =" from authors t1, titleauthor t2, titles t3"
  1523. A37    =FORMULA(A36,B36)
  1524. A38    =POKE(A4,"Xstr1",B36)
  1525. A39    =REQUEST(A4,"Dbcmd")
  1526. A40    =" where (t2.title_id=t3.title_id) and (t1.au_id=t2.au_id)"
  1527. A41    =FORMULA(A40,B40)
  1528. A42    =POKE(A4,"Xstr1",B40)
  1529. A43    =REQUEST(A4,"Dbcmd")
  1530. A44    =" order by t3.price desc"
  1531. A45    =FORMULA(A44,B44)
  1532. A46    =POKE(A4,"Xstr1",B44)
  1533. A47    =REQUEST(A4,"Dbcmd")
  1534. A48    =REQUEST(A4,"Dbsqlexec")
  1535. A49    =REQUEST(A4,"Dbresults")
  1536. A50    =REQUEST(A4,"Dbrows")
  1537. A51    =IF(A50="0",ALERT("Author Not Found",2))
  1538. A52    =SELECTION()
  1539. A53    =REFTEXT(SELECTION())
  1540. A54    =FORMULA(A53,B58)
  1541. A55    =POKE(A4,"Xstr1",B58)
  1542. A56    =REQUEST(A4,"Getexcel")
  1543. A57    =REQUEST(A4,"Txtdump")
  1544. A58    =RETURN()
  1545.  
  1546. The last macro found on the disk executes a single query to Microsoft SQL Server based on a specific 
  1547. author in the Pubs database.  It shows how to take advantage of the Dbconvert function.
  1548.  
  1549. B116    SQL.Query2
  1550. B117    =DIALOG.BOX(C30:I36)
  1551. B118    =IF(B117=FALSE,GOTO(B186))
  1552. B119    ="select t1.au_id, t2.title_id, t3.title, t3.price, t3. ytd_sales,t1.Au_fna
  1553. B120    =FORMULA(B119,C120)
  1554. B121    =POKE(A4,"Xstr1",C120)
  1555. B122    =REQUEST(A4,"Dbcmd")
  1556. B123    =" from authors t1, titleauthor t2, titles t3"
  1557. B124    =FORMULA(B123,C124)
  1558. B125    =POKE(A4,"Xstr1",C124)
  1559. B126    =REQUEST(A4,"Dbcmd")
  1560. B127    =" where (t1.au_fname='"&I34&"' and t1.au_lname='"&I36&"')"
  1561. B128    =FORMULA(B127,C128)
  1562. B129    =POKE(A4,"Xstr1",C128)
  1563. B130    =REQUEST(A4,"Dbcmd")
  1564. B131    =" and (t2.title_id=t3.title_id) and (t1.au_id=t2.au_id)"
  1565. B132    =FORMULA(B131,C132)
  1566. B133    =POKE(A4,"Xstr1",C132)
  1567. B134    =REQUEST(A4,"Dbcmd")
  1568. B135    =REQUEST(A4,"Dbsqlexec")
  1569. B136    =REQUEST(A4,"Dbresults")
  1570. B137    =REQUEST(A4,"Dbrows")
  1571. B138    =IF(B137=0,ALERT("Author Not Found",2))
  1572. B139    =WHILE(TRUE)
  1573. B140    =REQUEST(B109,"Dbnextrow")
  1574. B141    =IF(B140<>-1,GOTO(B186))
  1575. B142    1
  1576. B143    =POKE(B91,"Xstr1",B142)
  1577. B144    CHAR
  1578. B145    =POKE(B91,"Xstr2",B144)
  1579. B146    =REQUEST(B91,"Dbconvert")
  1580. B147    3
  1581. B148    =POKE(B91,"Xstr1",B147)
  1582. B149    CHAR
  1583. B150    =POKE(B91,"Xstr2",B149)
  1584. B151    =REQUEST(B91,"Dbconvert")
  1585. B152    4
  1586. B153    =POKE(B91,"Xstr1",B152)
  1587. B154    MONEY
  1588. B155    =POKE(B91,"Xstr2",B154)
  1589. B156    =REQUEST(B91,"Dbconvert")
  1590. B157    5
  1591. B158    =POKE(B91,"Xstr1",B157)
  1592. B159    INT4
  1593. B160    =POKE(B91,"Xstr2",B159)
  1594. B161    =REQUEST(B91,"Dbconvert")
  1595. B162    6
  1596. B163    =POKE(B91,"Xstr1",B162)
  1597. B164    CHAR
  1598. B165    =POKE(B91,"Xstr2",B164)
  1599. B166    =REQUEST(B91,"Dbconvert")
  1600. B167    7
  1601. B168    =POKE(B91,"Xstr1",B167)
  1602. B169    CHAR
  1603. B170    =POKE(B91,"Xstr2",B169)
  1604. B171    =REQUEST(B91,"Dbconvert")
  1605. B172    =FORMULA(B146)
  1606. B173    =SELECT("rc[1]")
  1607. B174    =FORMULA(B166)
  1608. B175    =SELECT("rc[1]")
  1609. B176    =FORMULA(B171)
  1610. B177    =SELECT("rc[1]")
  1611. B178    =FORMULA(B151)
  1612. B179    =SELECT("rc[1]")
  1613. B180    =FORMULA(B156)
  1614. B181    =SELECT("rc[1]")
  1615. B182    =FORMULA(B161)
  1616. B183    =SELECT("r[1]c[-5]")
  1617. B184    =NEXT()
  1618. B185    =RETURN()
  1619.  
  1620. The following is the macro for the dialog box in the SQL.Connect macro.
  1621.  
  1622.  
  1623.  
  1624. The following is the macro for the dialog box in the SQL.Query2 macro.
  1625.  
  1626.  
  1627.  
  1628. SQL SOFTLINK AND DBFAST/WINDOWS
  1629.  
  1630. dBFast/Windows is a dBase compiler for the Microsoft Windows environment.  It takes the dBase 
  1631. code and adds many windows functions as well as the DDE messages necessary to talk to SQL 
  1632. SoftLink and therefore Microsoft SQL Server.
  1633.  
  1634. DDE Statements
  1635.  
  1636. The DDE Statements used in the dBFast/Windows development environment are as follows:
  1637.  
  1638. Talk
  1639. Syntax: TALK TO <application> ABOUT <topic>
  1640.  
  1641. The Talk statement is similar to the Initiate() command in the other to front end applications 
  1642. described in that it creates a DDE Channel between the application being developed withe 
  1643. dBFast/Windows and SQL SoftLink.  This is the channel over which the DDE conversation 
  1644. will take place.  Application is the name of the other application.  Topic is the name of 
  1645. something being accessed in the other application.  In the case of SQL SoftLink the topic is 
  1646. "SQL".
  1647.  
  1648. Example:
  1649.  
  1650. TALK TO SQL_SoftLink ABOUT SQL
  1651.  
  1652. This establishes a link between your application and SQL SoftLink.
  1653.  
  1654. Contact()
  1655. Syntax:  Contact()
  1656.  
  1657. This DDE function is not found in the other two front end applications.  This function 
  1658. returns a logical value indicating whether or not there is an active DDE channel.
  1659.  
  1660. Example:
  1661.  
  1662. CONTACT()
  1663.  
  1664. With this function it is possible to determine whether or not there is a connection with the 
  1665. other application, for example SQL SoftLink.
  1666.  
  1667. Senddata()
  1668. Syntax:  Senddata(Item, Data)
  1669.  
  1670. Senddata() sends the string defined by Data to the item in SQL SoftLink specified in Item.
  1671.  
  1672. Example:
  1673.  
  1674. SENDDATA("UserName",name)
  1675.  
  1676. This sends the username defined by name to the item in SQL SoftLink defined as 
  1677. "UserName".
  1678.  
  1679. Request()
  1680. Syntax: Request(Item)
  1681.  
  1682. Request() requests the item in SQL SoftLink specified by Item.
  1683.  
  1684. Example:
  1685.  
  1686. x=REQUEST("Connect")
  1687.  
  1688. This requests that SQL SoftLink perform the "Connect" function across the DDE channel.
  1689.  
  1690. Terminate
  1691. Syntax:  Terminate
  1692.  
  1693. This will terminate the DDE channel opened up with the Talk command.
  1694.  
  1695. Example:
  1696.  
  1697. TERMINATE
  1698.  
  1699. This terminates the link between your application and SQL SoftLink that was created by the 
  1700. Talk command.
  1701.  
  1702. How to Implement
  1703.  
  1704. In order to access Microsoft SQL Server from the application being developed with dBFast/Windows 
  1705. through SQL SoftLink, the first thing needed is to make sure that SQL SoftLink is up and running 
  1706. (SQL SoftLink may be iconized.)  In addition, Microsoft SQL Server must be running on a server on 
  1707. the network.
  1708.  
  1709. To establish a DDE link between the application and SQL SoftLink the DDE statements need to be 
  1710. implemented in the program.
  1711.  
  1712. The first part of the program initiates the DDE channel between the two applications.  This is 
  1713. performed with the Talk statement.  For example:
  1714.  
  1715. TALK TO "SQL_SoftLink" ABOUT "SQL"
  1716.  
  1717. In order to connect to Microsoft SQL Server the server name, username, password and database 
  1718. need to be poked to SQL SoftLink.  Once this is accomplished a request needs to be sent to SQL 
  1719. SoftLink asking for the "Connect" function.  For example:
  1720.  
  1721. SENDDATA("Server",server)
  1722. SENDDATA("UserName",name)
  1723. SENDDATA("Pswd",password)
  1724. SENDDATA("Dbase",database)
  1725. x=REQUEST("Connect")
  1726.  
  1727. After these functions have been accomplished, there should be a connection between your application 
  1728. and Microsoft SQL Server through SQL SoftLink.  Now SQL statements can be passed to SQL 
  1729. SoftLink in order to receive queries from Microsoft SQL Server.  For example:
  1730.  
  1731. SENDDATA("Xstr1","select address, city, state, zip from authors")
  1732.  
  1733. The Senddata function sends the SQL statement to SQL SoftLink.
  1734.  
  1735. Next is to place this SQL statement in a buffer.  For example:
  1736.  
  1737. REQUEST("Dbcmd")
  1738.  
  1739. Additions to the SQL statement can be made by poking the information in the same manner as above 
  1740. and then requesting "Dbcmd."  Once the entire SQL statement is in the buffer, a series of SQL 
  1741. SoftLink functions need to be requested in order to execute the query.  The order of these is as 
  1742. follows.
  1743.  
  1744. REQUEST("Dbsqlexec")
  1745. REQUEST("Dbresults")
  1746. REQUEST("Dbrows")
  1747.  
  1748. Depending on the number of rows returned, a loop may be set up for the next section.  This next 
  1749. section retrieves the data obtained in the query.  First, a row of data needs to be read.  For example:
  1750.  
  1751. REQUEST("Dbnextrow")
  1752.  
  1753. Next, the data needs to be returned and converted.  This is done by calling the Dbconvert function in 
  1754. SQL SoftLink.  Before this function can be called, two parameters must be passed to it.  The first is 
  1755. the number of the item in the SQL statement.  For example in the SQL statement above:  address=1, 
  1756. city=2, state=3, etc.  The other parameter is the type of data that is being returned.  For example:
  1757.  
  1758. SENDDATA("Xstr1", "1")
  1759. SENDDATA("Xstr2", "CHAR")
  1760. addr=REQUEST("Dbconvert")
  1761. SENDDATA("Xstr1", "2")
  1762. SENDDATA("Xstr2", "CHAR")
  1763. city=REQUEST("Dbconvert")
  1764. SENDDATA("Xstr1", "3")
  1765. SENDDATA("Xstr2", "CHAR")
  1766. state=REQUEST("Dbconvert")
  1767. (etc.)
  1768.  
  1769. The data returned can now be formatted and manipulated with other dBFast/Windows functions and 
  1770. commands.
  1771.  
  1772. Once all work with Microsoft SQL Server is completed it is best to terminate the link.  First the 
  1773. connection to Microsoft SQL Server must be terminated and then terminate the DDE link between 
  1774. Microsoft Excel and SQL SoftLink.  For example:
  1775.  
  1776. REQUEST("Dbexit")
  1777. TERMINATE
  1778.  
  1779. Sample Program
  1780.  
  1781. ON the disk you will find a sample program written in dBFast/Windows that queries the Pubs 
  1782. database on Microsoft SQL Server.  The compiled program is SSLDBF.EXE.  The PRG for this 
  1783. program has also been provided; SSLDBF.PRG.
  1784.  
  1785. SUGGESTED IMPLEMENTATION AIDS
  1786.  
  1787. Integrating Applications Using Dynamic Data Exchange
  1788.     WexTech Systems, Inc.
  1789.     60 East 42nd Street
  1790.     New York, NY  10165
  1791.     (212)949-9595
  1792.  
  1793. Microsoft  Word for Windows Technical Reference Manual
  1794.  
  1795. Microsoft Excel Technical Reference Manual
  1796.  
  1797. DDEWatch by Horizon Technologies
  1798.  
  1799. This is an excellent product which allows a user to watch the DDE statements being 
  1800. passed between the client and server.  It is an excellent debugging tool.
  1801.  
  1802. Horizon Technologies Inc.
  1803. 2356 Science Parkway, Suite 100
  1804. Okemos, MI  48864
  1805. (517)347-0800
  1806.  
  1807.  
  1808. Microsoft Product Support for support in writing macros in Excel and Word for Windows.
  1809. (206)454-2030
  1810.  
  1811. Microsoft Online for information on implementing DDE.
  1812. FUTURE ENHANCEMENTS
  1813.  
  1814. Future upgrades and products that we are currently working on are:
  1815.     Microsoft SQL Server connection with OS/2 Presentation Manager
  1816.     Microsoft SQL Server connection with Superbase 4
  1817. REGISTRATION
  1818.  
  1819. By purchasing a copy of SQL SoftLink you are automatically registered and eligible for technical 
  1820. support.
  1821.  
  1822. TECHNICAL SUPPORT
  1823.  
  1824. If you have a technical question regarding SQL SoftLink please feel free to call us at (206)391-5099, 
  1825. Monday -Friday between 8:00am and 5:00pm Pacific Time, or write us at:
  1826.  
  1827. SQLSoft
  1828. 45 Front St., So., Suite B
  1829. Issaquah, WA 98027
  1830.  
  1831. We do not charge a fee for telephone support for the first 15 minutes during the initial 30 day period 
  1832. to ensure that you get all your questions answered.  If you need further technical support, you will be 
  1833. billed at the rate of $120.00 per hour or $20.00 for each 10 minute interval.  If you require 
  1834. customization work please contact us for our rates.
  1835.  
  1836. We appreciate all suggestions and notifications of possible bugs.
  1837. -------------------------------------------------------------------------------------------------------------------------------- 
  1838. SQL SoftLink- Copyright (c) 1990 SQLSoft.  All rights reserved (206)391-5099                                                                                            7
  1839.  
  1840.  
  1841.