Friday, July 30, 2010

MSAccess Dynamic Resizing of a form's contents

To change the dynamic height of a listbox is the only content of a form's detail section, attach the following code to the onResize event

Private Sub Form_Resize()

    '1440 twips = 1 inch
    'Stop setting the size if the inside height is less than an inch tall
    If (Me.InsideHeight / 1440 > 1) Then
        listBox1.Height = Me.InsideHeight - 1440
    End If

End Sub

Kudos to http://www.lebans.com/toc.htm

Wednesday, July 28, 2010

Various Alternatives to SMTP

I was excited to stumble into this article which showed a brief list of available open source web mail options:
http://www.roseindia.net/opensource/open-source-web-mail.shtml

It can ceate multi-part rich emails which allows you to send encoded images so you don't have to raise security red alerts by referencing images from the web.  The technology it uses to do this is an open-source library named  DotNetOpenMail

Tuesday, July 27, 2010

function for inspecting column data type and length

Run this tsql to create a function to which you can pass the table and column names as parameters. It will return the data type, length of the column specified
declare @sql varchar(1000) 
 if object_id('fn_GetColumnMetaData') is null 
 Begin
  print '    Creating function dbo.fn_GetColumnMetaData'
  set @sql = 'create function dbo.fn_GetColumnMetaData(@tblName varchar(100), @colName varchar(100))
   Returns Table
   as Return (
    select length=case when t.name=''nvarchar'' then c.length/2 else c.length end, maxLength=t.length, typeName=t.name
    from syscolumns c join systypes t on  c.xtype=t.xtype and t.name != ''sysname''
    where id=object_Id(@tblName) and c.name=@colName
   )'  
  exec(@sql)
 End 

Thursday, July 22, 2010

Getting started

Azure website: http://windows.azure.com/
Pricing: http://www.microsoft.com/windowsazure/pricing/

At a minimum you will pay $10/month for SQL Azure - for a 1 GB database.

Saturday, July 10, 2010

Saturday, July 03, 2010

Mongo DB

This article has a recommended reading list to get acquainted with mongoDB:

Friday, July 02, 2010

Gmail Notifier

The Gmail Notifier tool will give you a popup notification on your desktop when you get an email in your gmail inbox.

Thursday, July 01, 2010

JavascriptMVC - a fabulous framework

http://javascriptmvc.com/

I did a sample project with this.  Looks exciting, but there is definitely a learning curve.

There is a nice discussion of the merits of even attempting to do this in javascript here

Stored Procedure to Count Rows in Dynamic SQL

The first parameter contains the dynamic SQL string. The second parameter is an optional column name the count statement operates on; the default is *.

/*
 Counts the number of records in a dynamic sql string.  Example usage:
 declare @records int
 exec @records =  usp_CountRowsInDynamicSQL   'select recordId=5 union select recordId=6', 'recordId'
 print @records
 
*/
Create proc  usp_CountRowsInDynamicSQL (@sql varchar(800), @colNameToCount varchar(50) = '*' ) AS
 declare @rowCount int
 create table #tmpRowCount (row_Count int) 
 set nocount on
 set @sql = 'insert into #tmpRowCount (row_Count) select count(' + @colNameToCount + ') from ( ' + @sql + ') x'
 exec(@sql)
 set @rowCount = (select top 1 row_count from #tmpRowCount)  
 set @rowCount = isnull(@rowCount,0)   
 set nocount off
 drop table #tmpRowCount
 return @rowCount