select from a stored procedure

July 21, 2014

Declare @T Table (
logday datetime,
netid varchar(50),
swhere varchar(100),
datatext text ,
session varchar(100)
Insert @T Exec [ListRecentErrors]

select sdate , swhere as ErrorCategory , count(*) as ErrorCount from
Select CONVERT(varchar(12),logday,102) as sdate , swhere from @T
) A
group by sdate , swhere

we got this from StackOverflow


Excel rewrites your links! good luck sharepoint users …

July 18, 2014

A student and I struggled with this for about an hour … I don’t do sharepoint day-to-day …


visual studio poltergeist?

July 18, 2014

Visual Studio or somebody is looping infinitely on my web page!

Whenever I started my debugger, something would hit one of my pages (not me) – in a loop – and I had no idea what it was. I booted the pc, and it went away.

The way I could tell the problem was happening was that the victim page was missing some inputs and throwing exceptions in the code behind.

I don’t let our junior developers know about this kind of stuff – they believe in poltergeists as it is. (I hate to hear those uninformed anti-Microsoft rants…)

Wow – the poltergeist came back! Why? (what is stuck or hung in there?)

I killed a worker process for iis in task manager — no help.

I restarted IIS
net stop w3svc
net start w3svc

that fixed it!

stateless unit testing (when I wanted several to run together) … MemoryCache

July 15, 2014

Unit Testing – wow, I spent two days and the issue seems to have been just my misunderstanding of how stateless each unit test is.
I was trying to test a push and a pull from a local cache storage (instead of using web application cache, I switched to MemoryCache (.Net 4).

The problem was that I was saving in one test and trying to read in another test. And it’s an unfortunately long story, but when I finally just made one test method which saved and then read, it all worked.

I knew that I couldn’t count on tests being run in a certain order, but I was trying to run things by hand from Test Explorer. Sometimes it would work, but I just shot at least 12 hours trying to get something to work that I should have just spent 3 minutes on doing it the easy way.

mixed razor and html (a little beyond the simple examples you find at w3 school)

July 1, 2014

mixed razor and html (a little beyond the simple examples you find at w3 school)

(sorry about this post all in an image … I’m not skilled enough at word press to format all my bracket characters)

here is what finally worked
we took out as much razor as possible, and now I’m happy. I failed to catch another error in the image of all my travails with this – we got the system message that echoed to the screen, and the fix for that was to put in a “using” statement … and I could not get this to work in a reasonable amount of time. (less than 4-6 hours) Less razor is a good thing.

@Model.pagingLabelText mvc – mixing razor code with css

June 26, 2014

1) vb syntax
2) purpose: hide/show a div from razor (I realize it’s possible to do this easily in jquery)

the page/view:
Html.BeginForm(“results”, “Results” )



the css:
.dvPaging {
height: 20px;

the razor code:
I think it’s best to do what we need in a function.
I put presentation layer code in my view model

‘ purpose – called by the css to show or hide the paging section based on whether there are more than
‘ one page or not
Public Function NotPaged() As String
Dim sRet As String = “”
If (Not isPagination) Then sRet = “display:none; height:0px;”
Return sRet
End Function

spelunking oracle (generate sql queries)

January 7, 2014

a way to get an overview of a bunch of tables – I wanted to know what was useful in a database, so I listed up about 500 tables and looked at a brief snapshot of each.

This code:

select owner,object_name ,
'select '' '' as ' || object_name || ' , Q.* from ' || owner || '.' || object_name || ' Q where rownum < 100; ' as copyandexecute

from all_objects
where object_type='TABLE'
and owner in ('AAISP' )

generates these queries:


I had to learn how to get the string literals in there correctly … I don’t do Oracle day-to-day.

oracle connection from visual studio 2012 problem

January 7, 2014

I’ve been connecting to three or four oracle databases off and on for about 5 years.

In a new project, I added a new entry to TNSNames and tried to connect to a new database, and I spent close to 12 hours trying to get it to work.

I may have had a problem with my tnsnames entry … but what seemed to do it finally was this:

Oracle looks for the tnsnames.ora file in the directory defined in the TNS_ADMIN environment variable – If you are running as different users, then maybe the TNS_ADMIN environment variable is not set, and therefore it cannot find the file?

could we live without stack overflow?

also, in the process I made sure to install the ODAC stuff downloaded from

But the fact that visual studio server and also my programs could connect to other oracle databases also defined in the same tnsnames.ora file is something I may not ever understand.

generic list in vb

December 18, 2013

here’s a good link for reference:
and I also used:

1) we have a generic list: Private Shared m_ListLDAP As List(Of PersonPermission)

2) the class
Public Class PersonPermission
Public netid As String
Public campus As String
Public usertype As String

Public Sub New(snetid As String, slocation As String, stype As String)
netid = snetid
campus = slocation
usertype = stype
End Sub

Public Sub New()
End Sub

End Class

3) we load the list from a datatable
4) then later in the code, we find an element in the list based on the user netid, and return some values. Frankly, I don’t understand the syntax. To me, it looks like LINQ, but I guess the Find function of the generic list is calling my little inline delegate function … or something like that.

' ******************************************************************************************************************
' purpose - search the list on netid, return campus and usertype
Public Shared Sub get_ldap_override_values(ByVal netid As String, ByRef campus As String, ByRef usertype As String)

If (IsNothing(m_ListLDAP)) Then load_user_list()
campus = ""
usertype = ""
Dim myLocatedObject As PersonPermission = m_ListLDAP.Find(Function(p) p.netid = netid)
If (Not IsNothing(myLocatedObject)) Then
campus = myLocatedObject.campus
usertype = myLocatedObject.usertype
End If
End Sub

SQL DataReader problems

October 16, 2012

I may have a problem with a certain database server.

But I only see it when I use a DataReader.

The exception I get (sporadically – about 5% of the time, I think) is:

ERROR: System.NullReferenceException:
Object reference not set to an instance of an object.     at
System.Data.SqlClient.SqlDataReader.ReadColumnData()     at System.Data.SqlClient.SqlDataReader.ReadColumnHeader(Int32
i)     at System.Data.SqlClient.SqlDataReader.ReadColumn(Int32
i, Boolean setTimeout)     at
System.Data.SqlClient.SqlDataReader.GetValueInternal(Int32 i)     at
System.Data.SqlClient.SqlDataReader.GetValue(Int32 i)     at
System.Data.SqlClient.SqlDataReader.get_Item(String name)

Note – there are no null columns in my data, and this code has worked for years.

Sometimes it happens after reading 80 records, sometimes 30, sometimes 50. We’re not talking about 10K records here.

Here is the code where the exception occurs:

isdky = dreader.Item(“sdKy”)

I read a nice blog, and converted my code to use ordinal positions:  ‘

fldProductKey = dreader.GetOrdinal(“sdKy”)


ProductKey = dreader.GetInt32(fldProductKey)

But I got the same error.

When I converted my code to get a datatable, then loop through the rows, my troubles went away. I haven’t run that in production yet, but it looks very hopeful.

This points out that I don’t quite understand the process as a reader loops and reads. It seems like it loses its schema along the way and loses track of columns.

When I get a datatable, it pulls in everything, then I close the connection. It just works more stably. We’ve seen issues on this database server in the past – but those were with writes, not read like this time.