Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've written a couple of applications similar to the one you've described and while I can't pretend to offer <em>best practice</em> I can comment based on my personal experiences.</p> <p>• Can I give names to my columns and use them as a database column when sending the data back to SQLServer</p> <p><em>Sure why not, you can add the column names as the first row of an excel sheet and use the cell protection features to prevent tampering by the end user. You need to associate the columns of data in excel with the underlying fields in SQL Server somehow and this is as good a way as any.</em></p> <p>• If I want to use normalized data like for LookupTable (ID, Country) should I store the ID, Country information in a Range and if so, how do I force the user to pick a value from that Range (ID, Country) without using a proper Combobox?</p> <p><em>You can create individual (hidden) sheets for each lookup table and enforce selection using code something like this (based on a macro recording so this could be cleaned up)</em></p> <pre><code> With Sheet1.Range("E3").Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1:="=B2:B5" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "A sample" .ErrorTitle = "An error" .InputMessage = "Input message" .ErrorMessage = "Error message" .ShowInput = True .ShowError = True End With </code></pre> <p><em>This will give you a combo box in cell, an error message on failed validation and a title for the cell.</em></p> <p>• When I retrieve back the data what's expected of a spreadsheet app that I for example retrieve ID, Description (hiding the ID in a column and showing the Description) or should I just use the Description for everything and store denormalized data in my SQLServer tables, making them the equivalent of a server side Excel sheet?</p> <p><em>It would work either way. I’d probably decide based on the complexity of the data. If you’re needing to build lots of validation code in VBA I’d be tempted to pull denormalised data into staging tables in SQL Server and then denormalise using stored procs before moving the data to your main tables. YMMV.</em></p> <p>• When I retrieve the data from SQLServer should I model it into an ADODB.Recordset (for example by calling a view or a stored procedure) and copy it to the Sheet making sure the order of fields in the Recordset is the same as in the Sheet or is there a better way?</p> <p><em>I'd avoid using copy and paste as it uses a system wide clipboard and odd things can start happening if you're using the PC at the sametime. The range object in excel has a CopyFromRecordset method that you can use to push the data from ADO to a worksheet. It's a lot faster than iterating through the recordset assigning manually. The only downside is that you'll have to create the header columns yourself beforehand.</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload