Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Below is the code, placed in the CLICK event of the Populate Combo Box button, that populates the combo box.  The The code is almost identical to the code for populating the combo box from Access. In fact, it is impossible to determine, just by looking at the code, where the data is coming from.

...

In the code, the differences between the two programs is highlighted.  They They are:

  • Changing the connection name.  Use Use PUBS instead of NWIND.  AdditionallyAdditionally, Access does not require a user name.  SQL SQL Server does require a user name, which we specify as sa, the System Administrator.  Your Your user name may be different.  It It almost certainly is if you're not the System Administrator.  You You also may need a password, which is the fourth parameter to QryInstance().  Consult Consult your database administrator.

  • Changing the SQL Select statement.   Since the table and columns are different, it makes sense that the SQL Select statement to be executed will change.

  • Changing the Combo Box Name.  Control Control names should be easily referenced.  In In this example, since the combo box is populated with author names, we named itit AUTHORS.

...

Code Block
$insert XO_Equates
hXO = XOInstance('PUBS' , '', 'sa')
if hXO then
  hQry = QryInstance(hXO)
    if hQry then
      flag = QryMethod(hQry, QRY_EXECUTE$, "select au_lname + ', ' + au_fname from authors order by au_lname")
      row = ""
      results = ""
      loop
        flag = QryMethod(hQry, QRY_GETROW$, row)
      while flag
        results<-1> = row
      repeat
      QryMethod(hQry, QRY_DESTROY$)
    end
  rv = Set_Property (@window : '.AUTHORS', 'LIST', results)
  XOMethod(hXO, XO_DESTROY$)
end