Thursday, December 24, 2009

Official Project Website

The official website for our final year project epZilla was launched.
http://www.epzilla.net/

Sunday, October 18, 2009

Passing Parameters to A Crystal Report from Code Behind ~ ASP.NET

In a resent project i had to pass parameters to a crystal report depending on a user selection of a dropdownlist, this is how i achieved it in VB.NET.

The server name and DBname are stored in the web.config

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
ReportLocation = System.IO.Path.Combine(Server.MapPath("~"), "Admin\Report1.rpt")
ServerName = ConfigurationManager.AppSettings("ServerName")
DBName = ConfigurationManager.AppSettings("DBName")
SetSource(DropDownList1.SelectedValue)
End Sub

Sub SetSource(ByVal params As String)
Dim cryRpt As New ReportDocument()
Dim crtableLogoninfos As New TableLogOnInfos()
Dim crtableLogoninfo As New TableLogOnInfo()
Dim crConnectionInfo As New ConnectionInfo()
Dim CrTables As Tables
cryRpt.Load(ReportLocation)
crConnectionInfo.ServerName = ServerName
crConnectionInfo.DatabaseName = DBName
crConnectionInfo.IntegratedSecurity = True
CrTables = cryRpt.Database.Tables
For Each CrTable As CrystalDecisions.CrystalReports.Engine.Table In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next

Dim parameters As New ParameterFields
Dim param As ParameterField
Dim paramvalue As ParameterDiscreteValue
CrystalReportViewer1.ReportSource = cryRpt
parameters.Clear()

param = New ParameterField
paramvalue = New ParameterDiscreteValue
param.Name = "Param1"
paramvalue.Value = params
param.CurrentValues.Add(paramvalue)
param.HasCurrentValue = True
parameters.Add(param)
CrystalReportViewer1.ParameterFieldInfo = parameters
End Sub

Avoid Navigating to previuos pages in Firefox ~ ASP.NET

I got a problem in asp.net where a user after logging out can navigate back to the pages that he visited previously without again logging in. The problem comes because the pages are not retrieved from the server but stored in the browser cache.This is how i avoided it.

I included this code in the page load of each page

Response.Buffer = True
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1D)
Response.Expires = 0
Response.Cache.SetNoStore()
Response.AppendHeader("Pragma", "no-cache")
Response.CacheControl = "no-cache"
If Not Page.User.Identity.IsAuthenticated Then
Response.Redirect("~/login.aspx", False)
End If

Friday, September 11, 2009

Project epZilla

Our Final year project is underway, http://epzilla.blogspot.com/
WOW............

Sunday, June 7, 2009

T-SQL CREATE LOGIN and CREATE USER Statements

I recently did a project involving MS SQL server native user and login management. This is is the Script that i used to create the SP needed.

CREATE PROC [dbo].[usp_CreateLoginAndUser]
@Login sysname,
@Password sysname
AS
DECLARE @CreateLoginStatement nvarchar(200)

SET @CreateLoginStatement = 'CREATE LOGIN ' +
QUOTENAME(@Login) +
' WITH PASSWORD = ' +
QUOTENAME(@Password, '''')+';'+
' CREATE USER ' +
QUOTENAME(@Login) +
' FOR LOGIN ' +
QUOTENAME(@Login) +';'

EXEC sp_executesql @CreateLoginStatement


this SP creates a MS SQL server User login and a database User at the same time.

Wednesday, May 6, 2009

Lightbox JS-

Lightbox JS is great way to arrange your image gallery on your web site. its really cool cheack it out.
I tried it out with ASP.NET 3.5. works really well.