Using Excel VBA to Copy an ADODB Recordset to Multiple Worksheets

Microsoft VBA logo

In adding functionality to an ancient Excel VBA reporting app for an Oracle database, I decided to set up a temporary worksheet to use as a place to store data before copying it to multiple other worksheets rather than copying directly from the recordset multiple times.

Basically, this VBA procedure takes an ADODB recordset and a Boolean value as parameters. The recordset is the data source, and the Boolean indicates whether or not the data will be copied to a particular worksheet. The temporary worksheet is cleared before the recordset is copied into it, and is cleared again after the data is copied to the other worksheet(s).

Public Sub CopyToSheets(ByRef rs As ADODB.Recordset, ByVal bCopyToSecondSht As Boolean)
    Dim MainSht As Worksheet, TempSht As Worksheet, Rng As Range, c As Range, lastRow As Long, intNextRow As Integer

    Set MainSht = ActiveWorkbook.Worksheets(cMainSht)
    Set TempSht = ActiveWorkbook.Worksheets(cTempData)

    TempSht.Cells.Clear

    rs.Open
    TempSht.Cells(1, 1).CopyFromRecordset rs
    rs.Close

    lastRow = TempSht.Range("A" & Rows.count).End(xlUp).Row
    Set Rng = TempSht.Range("A1:A" & lastRow)
    For Each c In Rng
        intNextRow = NextRowNumber(MainSht)
        c.EntireRow.Copy MainSht.Cells(intNextRow, 1)
        If bCopyToSecondSht Then
            Dim SecondSht As Worksheet
            Set SecondSht = ActiveWorkbook.Worksheets(cSecondSht)
            intNextRow = NextRowNumber(SecondSht)
            c.EntireRow.Copy SecondSht.Cells(intNextRow, 1)
        End If
    Next c
    TempSht.Cells.Clear
End Sub

Storing Session State for an ASP.NET Site in a SQL Server Database

ASP.NET and related technologies

When using session state in an ASP.NET Web application, you have several options.

If you want to store it in your application database, as opposed to the ASPstate database (created at the command line with “aspnet_regsql -S [server] -E -ssadd -sstype c -d ASPstate”), I have scripted the database objects and stored them in GitHub at this address:

https://github.com/DeepInTheCode/ASPstate

Replace the name of the database throughout the ASPstate.sql file with your application database name and run against the database. After that, the web.config of your Web application must have the appropriate information added:

<configuration>
	<system.web>
	<sessionState mode="SQLServer"
		sqlConnectionString="Integrated Security=SSPI;data
		source=SampleSqlServer;" 
	/>
	</system.web>
</configuration>

(sqlConnectionString must be set to your database with respective authentication information.)

Fixing the “Unknown Error code during application install: ‘-24′” Issue

Android Jelly Bean logo

I just finished installing the CyanogenMod ROM for Android Jelly Bean 4.1.2 (cm-10-20130117-1903-otter-sgt7.zip) on my rooted 1st generation Amazon Kindle Fire. I am very pleased to say that it boots much faster than the stock Amazon-loaded OS (forked Android Gingerbread 2.3)!

Loading another ROM removed the Amazon Marketplace, but does not load Google Play. After loading CM10, Google Apps (gapps) must still be loaded in order to get Google Play. Once this is done, Android apps – including the Kindle reader – can be reloaded.

The problem is that after loading CM10, some apps would not install correctly using Google Play. The Kindle Reader app in particular gave an error that was particularly vague: “Unknown Error code during application install: ‘-24′”.

Fortunately, the fix for this is rather simple. After loading Google Apps, do a factory reset using TWRP or whatever boot loader you’ve installed on the Fire. From what I’ve read, this may apply to other Android devices as well.