Sunday, August 24, 2008

Lock and Unlock folder

To lock folder

Create a text file on the same path where your folder resides and write (e.g. if u want to lock folder on d:\ then create these files on d:\)

ren lockfolderName lockfolderName.{21EC2020-3AEA-1069-A2DD-08002B30309D}

then save this file with extension ".bat"

To unlock folder

Create a text file on the same path where your folder resides and write
ren lockfolderName.{21EC2020-3AEA-1069-A2DD-08002B30309D} lockfolderName
then save this file with extension ".bat"

Monday, June 2, 2008

Stored Procedure to Search Value in Database

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go



ALTER PROC [dbo].[SearchAllTables]
(
@SearchStr nvarchar(100)
)
AS
BEGIN



CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))

SET NOCOUNT ON

DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)
SET @TableName = ''
SET @SearchStr2 = QUOTENAME('' + @SearchStr + '','''')

WHILE @TableName IS NOT NULL
BEGIN
SET @ColumnName = ''
SET @TableName =
(
SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
AND OBJECTPROPERTY(
OBJECT_ID(
QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
), 'IsMSShipped'
) = 0
)

WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)
BEGIN
SET @ColumnName =
(
SELECT MIN(QUOTENAME(COLUMN_NAME))
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = PARSENAME(@TableName, 2)
AND TABLE_NAME = PARSENAME(@TableName, 1)
AND DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')
AND QUOTENAME(COLUMN_NAME) > @ColumnName
)

IF @ColumnName IS NOT NULL
BEGIN
INSERT INTO #Results
EXEC
(
'SELECT distinct ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630)
FROM ' + @TableName + ' (NOLOCK) ' +
' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
)
END
END
END

SELECT ColumnName, ColumnValue FROM #Results
END

Monday, May 19, 2008

Fix for Invalid Viewstate error

http://community.discountasp.net/default.aspx?f=24&m=10014&g=10785

Thursday, April 10, 2008

Sharepoing Installation steps

http://www.codeproject.com/KB/sharepoint/MOSS_2007__Installation.aspx

Monday, March 17, 2008

CSV Problem

http://msdn2.microsoft.com/en-us/library/ms974559.aspx

Monday, March 3, 2008

create Virtual Directory using C#

http://www.vbforums.com/showthread.php?t=347207

Code to create Virtual Directory using C#

  1. Private Sub CreateVirtualDir(ByVal WebSite As String, ByVal AppName As String, ByVal Path As String)
  2. Dim IISSchema As New System.DirectoryServices.DirectoryEntry("IIS://" & WebSite & "/Schema/AppIsolated")
  3. Dim CanCreate As Boolean = Not IISSchema.Properties("Syntax").Value.ToString.ToUpper() = "BOOLEAN"
  4. IISSchema.Dispose()
  5. If CanCreate Then
  6. Dim PathCreated As Boolean
  7. Try
  8. Dim IISAdmin As New System.DirectoryServices.DirectoryEntry("IIS://" & WebSite & "/W3SVC/1/Root")
  9. 'make sure folder exists
  10. If Not System.IO.Directory.Exists(Path) Then
  11. System.IO.Directory.CreateDirectory(Path)
  12. PathCreated = True
  13. End If
  14. 'If the virtual directory already exists then delete it
  15. For Each VD As System.DirectoryServices.DirectoryEntry In IISAdmin.Children
  16. If VD.Name = AppName Then
  17. IISAdmin.Invoke("Delete", New String() {VD.SchemaClassName, AppName})
  18. IISAdmin.CommitChanges()
  19. Exit For
  20. End If
  21. Next VD
  22. 'Create and setup new virtual directory
  23. Dim VDir As System.DirectoryServices.DirectoryEntry = IISAdmin.Children.Add(AppName, "IIsWebVirtualDir")
  24. VDir.Properties("Path").Item(0) = Path
  25. VDir.Properties("AppFriendlyName").Item(0) = AppName
  26. VDir.Properties("EnableDirBrowsing").Item(0) = False
  27. VDir.Properties("AccessRead").Item(0) = True
  28. VDir.Properties("AccessExecute").Item(0) = True
  29. VDir.Properties("AccessWrite").Item(0) = False
  30. VDir.Properties("AccessScript").Item(0) = True
  31. VDir.Properties("AuthNTLM").Item(0) = True
  32. VDir.Properties("EnableDefaultDoc").Item(0) = True
  33. VDir.Properties("DefaultDoc").Item(0) = "default.htm,default.aspx,default.asp"
  34. VDir.Properties("AspEnableParentPaths").Item(0) = True
  35. VDir.CommitChanges()
  36. 'the following are acceptable params
  37. 'INPROC = 0
  38. 'OUTPROC = 1
  39. 'POOLED = 2
  40. VDir.Invoke("AppCreate", 1)
  41. Catch Ex As Exception
  42. If PathCreated Then
  43. System.IO.Directory.Delete(Path)
  44. End If
  45. Throw Ex
  46. End Try
  47. End If
  48. End Sub