Thursday, October 18, 2007

Popfly

Popfly is the new mashup tool from Microsoft based on their Silverlight technology. If you're in to social networking, you can use it to be the envy of all your friends. Check it out:
http://www.popfly.com
http://www.popfly.ms/users/admiller97/Pictures

Friday, July 27, 2007

Execute stored procedure in SSMS


declare @ActiveRegistrationCode varchar(10)
set @ActiveRegistrationCode='BV04MP6C'
exec ENT.DelActiveRegistrationCode @ActiveRegistrationCode

Wednesday, June 20, 2007

C# random number, random string generator


private string GetRandomString(int pLength, bool pIncludeNumbers, bool pIncludeCharacters)
{
//ensure at least one option is selected
if (!pIncludeNumbers && !pIncludeCharacters)
return String.Empty;

StringBuilder result = new StringBuilder();
Random randomGen = new Random();
int randomNum;
int maxRandom;
int minRandom;

if (pIncludeNumbers)
maxRandom = 37;
else
maxRandom = 27;

if (pIncludeCharacters)
minRandom = 1;
else
minRandom = 27;

for (int counter = 0; counter < pLength; counter++)
{
randomNum = randomGen.Next(minRandom, maxRandom);
if (randomNum < 27)
result.Append(Convert.ToChar(randomNum + 64)); //65 = A
else
result.Append(Convert.ToString(randomNum - 27));
}
return result.ToString();
}

Wednesday, May 2, 2007

T-SQL IF THEN ELSE Control Flow


CREATE PROCEDURE [NBS].SelContextLabel
@ContextInd bigint,
@RowPrimaryKeyID nvarchar(100)
AS
BEGIN
Declare @SQL nvarchar(1000)

IF (@ContextInd = 1)
SET @SQL = 'SELECT ''UnitTest'''
ELSE IF (@ContextInd = 2)
SET @SQL = 'SELECT Firstname + '' ''+ Lastname FROM NBS.Person WHERE PersonID=' + @RowPrimaryKeyID
ELSE IF (@ContextInd = 3)
SET @SQL = 'SELECT InstName FROM NBS.Inst WHERE InstID = ' + @RowPrimaryKeyID
ELSE
SET @SQL = 'SELECT '''''

Execute(@SQL)
END

Monday, April 30, 2007

T-SQL Select data into variable

CREATE PROCEDURE ForeignLookup
@LookupID int
AS
BEGIN
DECLARE
@MyVariable nvarchar(100),

SELECT @MyVariable = ForeignValue From LookupTable
Where LookupTableID = @LookupID

--Do something with @MyVariable
END

Tuesday, April 17, 2007

Datagrid Paging


<asp:datagrid id="DataGrid1" runat="server" AllowPaging="True"
PageSize="5"></asp:datagrid>

    Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
'Fill the Dataset
Dim ds As New DataSet()
ds.ReadXml(Server.MapPath(".") & "\..\Xml\PartList.xml")

'Set the DataGrid's Source and bind it.
DataGrid1.DataSource = ds
If Not IsPostBack Then
DataGrid1.DataBind()
End If

'Dispose Items
ds.Dispose()
End Sub

'Implement the EventHandler for PageIndexChanged
Private Sub ChangePage(ByVal source As Object, ByVal e As _
System.Web.UI.WebControls.DataGridPageChangedEventArgs) _
Handles DataGrid1.PageIndexChanged
DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.DataBind()
End Sub