Archive for April, 2008

Total Disaster at Three Floyds

Monday, April 28th, 2008

Yep, it was that time of year again. Dark Lord Day! We got up early to head down the Munster Indiana for a very fine beer. Like last year, the people at 3F’s thought we would have a good time standing in a ridiculous like with hundreds other. The problem is they sold out. We spent 4 and half hours waiting in line and walked away empty handed. The people in front of us drove from Mobile Alabama the night before and left with nothing.
On top of that I didn’t like the new crowd. Craft beer is all about sharing and getting people to see there is more to beer than Bud Light. So, I was happy to see that there were more people. I didn’t like how many of them were planning to sell what they got. F**k those vultures.

Request.QueryString, MapPath and other things lost in a vb class

Monday, April 21st, 2008

I’ve added more parameters to VB classes I’m going to use in an ASP.NET website than I needed to because I didn’t know how to do simple things like MapPath in a class. To get your Request, Response and Server objects back simply call them with in the current http context

Dim x As String
X = System.Web.HttpContext.Current.Server.MapPath(”/img.jpg”)

Or

Import System.Web.HttpContext
Dim x As String
X = Current.Request.QueryString(”param”)

Using the IN clause with a string of comma delimited integers

Friday, April 18th, 2008

Rewriting some stored procedures I ran into a problem. As a parameter I had a series of comma separated integers stored in an nvarchar. I wanted to use this parameter in an β€œIN” statement.
Something like:

select @ids = β€˜1,2,3,5,6,7′
select *
from table
where id in (@ids)

With a function found at http://www.sqlteam.com/article/using-a-csv-with-an-in-sub-select, I can do this:

select @ids = β€˜1,2,3,5,6,7′
select *
from table
where id in (Select IntValue from dbo.CsvToInt(@ids) )

The function is:

Create Function dbo.CsvToInt ( @Array varchar(1000))
returns @IntTable table
(IntValue int)
AS
begindeclare @separator char(1)
set @separator = ‘,’

declare @separator_position int
declare @array_value varchar(1000)

set @array = @array + ‘,’

while patindex(’%,%’ , @array) <> 0
begin

select @separator_position = patindex(’%,%’ , @array)
select @array_value = left(@array, @separator_position - 1)

Insert @IntTable
Values (Cast(@array_value as int))

select @array = stuff(@array, 1, @separator_position, ”)
end

return
end