Wednesday, 24 August 2016

C# How to implement method that return list of SQL result?

Thursday, 28 January 2016

Update COMPATIBILITY_LEVEL for all databases in sql server



USE MASTER DECLARE GET_DATABASES CURSOR READ_ONLY FOR SELECT NAME FROM SYS.DATABASES WHERE COMPATIBILITY_LEVEL != '120' DECLARE @DATABASENAME NVARCHAR(255) DECLARE @COUNTER INT SET @COUNTER = 1 OPEN GET_DATABASES FETCH NEXT FROM GET_DATABASES INTO @DATABASENAME WHILE (@@fetch_status <> -1) BEGIN IF (@@fetch_status <> -2) BEGIN -- CHANGE DATABASE COMPATIBILITY EXECUTE sp_dbcmptlevel @DATABASENAME , '120' PRINT @DATABASENAME + ' changed' SET @COUNTER = @COUNTER + 1 END FETCH NEXT FROM GET_DATABASES INTO @DATABASENAME END CLOSE GET_DATABASES DEALLOCATE GET_DATABASES GO

Wednesday, 26 August 2015

OLAP configuration using powershell

#Import Modules
Import-Module WebAdministration

# change these settings 
$iisSiteName = "OLAP"
$iisPort = "8000"
$olapServerName = "server\instance"

# optionally also change these settings
$isapiFiles = "c:\Program Files\Microsoft SQL Server\MSAS11.MSSQLSERVER\OLAP\bin\isapi\*"
$iisAbsolutePath = "C:\inetpub\wwwroot\" + $iisSiteName
$iisAppPoolName = $iisSiteName + "_AppPool"
$iisAppPoolUser = "" #default is ApplicationPoolIdentity
$iisAppPoolPassword = ""
$iisAuthAnonymousEnabled = $false
$iisAuthWindowsEnabled = $true
$iisAuthBasicEnabled = $true
$olapSessionTimeout = "3600" #default
$olapConnectionPoolSize = "100" #default

if(!(Test-Path $iisAbsolutePath -pathType container))
{
    #Creating Directory
    mkdir $iisAbsolutePath  | Out-Null

    #Copying Files
    Write-Host -NoNewline "Copying ISAPI files to IIS Folder ... "
    Copy -Path $isapiFiles -Destination $iisAbsolutePath -Recurse
    Write-Host " Done!" -ForegroundColor Green
}
else
{
    Write-Host "Path $iisAbsolutePath already exists! Please delete manually if you want to proceed!" -ForegroundColor Red
    Exit
}

#Check if AppPool already exists
if(!(Test-Path $("IIS:\AppPools\" + $iisAppPoolName) -pathType container))
{
    #Creating AppPool
    Write-Host -NoNewline "Creating ApplicationPool $iisAppPoolName if it does not exist yet ... "
    $appPool = New-WebAppPool -Name $iisAppPoolName
    $appPool.managedRuntimeVersion = "v2.0"
    $appPool.managedPipelineMode = "Classic"

    $appPool.processModel.identityType = 4 #0=LocalSystem, 1=LocalService, 2=NetworkService, 3=SpecificUser, 4=ApplicationPoolIdentity
    #For details see http://www.iis.net/configreference/system.applicationhost/applicationpools/add/processmodel

    if ($iisAppPoolUser -ne "" -AND $iisAppPoolPassword -ne "") {
     Write-Host 
        Write-Host "Setting AppPool Identity to $iisAppPoolUser"
  $appPool.processmodel.identityType = 3
  $appPool.processmodel.username = $iisAppPoolUser
  $appPool.processmodel.password = $iisAppPoolPassword
 } 
    $appPool | Set-Item
    Write-Host " Done!" -ForegroundColor Green
}
else
{
    Write-Host "AppPool $iisAppPoolName already exists! Please delete manually if you want to proceed!" -ForegroundColor Red
    Exit
}

#Check if WebSite already exists
$iisSite = Get-Website $iisSiteName
if ($iisSite -eq $null)
{
    #Creating WebSite
    Write-Host -NoNewline "Creating WebSite $iisSiteName if it does not exist yet ... "
    $iisSite = New-WebSite -Name $iisSiteName -PhysicalPath $iisAbsolutePath -ApplicationPool $iisAppPoolName -Port $iisPort
    Write-Host " Done!" -ForegroundColor Green
}
else
{
    Write-Host "WebSite $iisSiteName already exists! Please delete manually if you want to proceed!" -ForegroundColor Red
    Exit
}

#Ensuring ISAPI CGI Restriction entry exists for msmdpump.dll
if ((Get-WebConfiguration "/system.webServer/security/isapiCgiRestriction/add[@path='$iisAbsolutePath\msmdpump.dll']") -eq $null)
{
    Write-Host -NoNewline "Adding ISAPI CGI Restriction for $iisAbsolutePath\msmdpump.dll ... "
    Add-WebConfiguration "/system.webServer/security/isapiCgiRestriction" -PSPath:IIS:\  -Value @{path="$iisAbsolutePath\msmdpump.dll"}
    Write-Host " Done!" -ForegroundColor Green
}
#Enabling ISAPI CGI Restriction for msmdpump.dll
Write-Host -NoNewline "Updating existing ISAPI CGI Restriction ... "
Set-WebConfiguration "/system.webServer/security/isapiCgiRestriction/add[@path='$iisAbsolutePath\msmdpump.dll']/@allowed" -PSPath:IIS:\ -Value "True" 
Set-WebConfiguration "/system.webServer/security/isapiCgiRestriction/add[@path='$iisAbsolutePath\msmdpump.dll']/@description" -PSPath:IIS:\ -Value "msmdpump.dll for SSAS"
Write-Host " Done!" -ForegroundColor Green


#Adding ISAPI Handler to WebSite
Write-Host -NoNewline "Adding ISAPI Handler ... "
Add-WebConfiguration /system.webServer/handlers -PSPath $iisSite.PSPath -Value @{name="msmdpump"; path="*.dll"; verb="*"; modules="IsapiModule"; scriptProcessor="$iisAbsolutePath\msmdpump.dll"; resourceType="File"; preCondition="bitness64"}
Write-Host " Done!" -ForegroundColor Green

#enable Windows and Basic Authentication
Write-Host -NoNewline "Setting Authentication Providers ... "
#need to Unlock sections first
Set-WebConfiguration /system.webServer/security/authentication/anonymousAuthentication  MACHINE/WEBROOT/APPHOST -Metadata overrideMode -Value Allow
Set-WebConfiguration /system.webServer/security/authentication/windowsAuthentication  MACHINE/WEBROOT/APPHOST -Metadata overrideMode -Value Allow
Set-WebConfiguration /system.webServer/security/authentication/basicAuthentication  MACHINE/WEBROOT/APPHOST -Metadata overrideMode -Value Allow

Set-WebConfiguration /system.webServer/security/authentication/anonymousAuthentication -PSPath $iisSite.PSPath -Value @{enabled=$iisAuthAnonymousEnabled}
Set-WebConfiguration /system.webServer/security/authentication/windowsAuthentication -PSPath $iisSite.PSPath -Value @{enabled=$iisAuthWindowsEnabled}
Set-WebConfiguration /system.webServer/security/authentication/basicAuthentication -PSPath $iisSite.PSPath -Value @{enabled=$iisAuthBasicEnabled}
Write-Host " Done!" -ForegroundColor Green

#Adding Default Document
Write-Host -NoNewline "Adding Default Document msmdpump.dll ... " 
Add-WebConfiguration /system.webServer/defaultDocument/files -PSPath $iisSite.PSPath -atIndex 0 -Value @{value="msmdpump.dll"}
Write-Host " Done!" -ForegroundColor Green

#Updating OLAP Server Settings
Write-Host -NoNewline "Updating OLAP Server Settings ... "
[xml]$msmdpump = Get-Content "$iisAbsolutePath\msmdpump.ini"
$msmdpump.ConfigurationSettings.ServerName = $olapServerName
$msmdpump.ConfigurationSettings.SessionTimeout = $olapSessionTimeout
$msmdpump.ConfigurationSettings.ConnectionPoolSize = $olapConnectionPoolSize
$msmdpump.Save("$iisAbsolutePath\msmdpump.ini")
Write-Host " Done!" -ForegroundColor Green

Thursday, 25 December 2014

writing file using vbscript

'Option Explicit
dim objXML2,fso,strdir,CurrentDirectory,ExportFile,LocalPath,SVNPath,colNodes,objnode
Set objXML2 = CreateObject("Microsoft.XMLDOM")
objXML2.async = "false"
strdir=WScript.Arguments.item(0)'PRODUCTINFO.xml

set fso = CreateObject("Scripting.FileSystemObject")
CurrentDirectory = fso.GetAbsolutePathName(".")
Set ExportFile = fso.CreateTextFile(CurrentDirectory&"\SVNExport.cmd", True)
ExportFile.WriteLine("@echo off")
'ExportFile.WriteLine("start /b 1")

LocalPath = 'WScript.Arguments.item(1)
SVNPath = 'WScript.Arguments.item(2)

'ExportFile.WriteLine("LocalPath: " & LocalPath)
'ExportFile.WriteLine("SVNPath: " & SVNPath)

If (Not objXML2.load(strdir)) Then
    wscript.echo "Unable to load file '" & strdir & "'. "
    WScript.Quit(1)
End If

Set colNodes = objXML2.selectNodes ("/PRODUCTINFO/PRODUCT")
For Each objNode in colNodes
    wscript.echo objnode.getAttribute("NAME")& " : " & objnode.getAttribute("VERSION")
ExportFile.WriteLine("echo Getting " & objnode.getAttribute("NAME") & " of version " & objnode.getAttribute("VERSION") & " from SVN")
ExportFile.WriteLine("""C:\Program Files\TortoiseSVN\bin\svn.exe"" export """ & SVNPath & "/" & objnode.getAttribute("NAME") & "/" & objnode.getAttribute("VERSION") & """   """ & LocalPath & "\" & objnode.getAttribute("NAME") & "\" & objnode.getAttribute("VERSION"))
Next
ExportFile.WriteLine("echo Export Completed")
ExportFile.close()

Thursday, 9 October 2014

SSL Settings automation using netsh and appcmd

appcmd set site "Default Web Site" /+bindings.[protocol='https',bindingInformation='*:443:']
======================================================================

# get the thumbprint for the certificate we want to use:
$thumb = (Get-ChildItem cert:\LocalMachine\MY | where-object { $_.FriendlyName -eq   "www.stackoverflow.com" } | Select-Object -First 1).Thumbprint
# get a new guid:
$guid = [guid]::NewGuid()

# remove the self-signed certificate:
& netsh http delete sslcert ipport=0.0.0.0:8172
# add the 'proper' certificate:
& netsh http add sslcert ipport=0.0.0.0:8172 certhash=$thumb appid=`{$guid`}


more information

http://www.iis.net/learn/manage/powershell/powershell-snap-in-configuring-ssl-with-the-iis-powershell-snap-in







Tuesday, 12 August 2014

links for the COM+ registering



http://msdn.microsoft.com/en-us/library/tzat5yw6(v=vs.110).aspx

http://www.codeproject.com/Articles/7859/Building-COM-Objects-in-C

http://community.microfocus.com/borland/define/caliber_-_requirements_management/w/knowledge_base/16090.why-when-registering-the-helloworld2-vbnet-dll-does-it-generate-the-error-regasm-warning-ra0000-no-types-were-registered.aspx


http://stackoverflow.com/questions/1847763/problem-registering-a-dll-access-denied


http://msdn.microsoft.com/en-us/library/dd233108(v=vs.110).aspx


http://www.codeproject.com/Articles/1405/Using-the-Web-Services-and-COM-Event-System-in-the

http://www.codeproject.com/Articles/206412/Reflection-An-Introduction-to-Reflection-in-NE


http://www.codeproject.com/Articles/337535/Understanding-the-Basics-of-Web-Service-in-ASP-NET

http://msdn.microsoft.com/en-us/magazine/cc301491.aspx

http://oreilly.com/catalog/comdotnetsvs/chapter/ch10.html

http://my.execpc.com/~gopalan/dotnet/complus/complus.net_accountmanager.html

http://www.codeproject.com/Articles/1511/Accessing-COM-component-using-C

http://edndoc.esri.com/arcobjects/9.2/NET/3a2694e6-32da-4e1e-b7c5-ccd3826161bb.htm

http://www.codeproject.com/Articles/206412/Reflection-An-Introduction-to-Reflection-in-NE

http://www.jagjot.com/2014/01/register-c-vb-net-dll-regasm-gacutil/


Friday, 8 August 2014

How to create the COM DLL

http://www.codeproject.com/Articles/7859/Building-COM-Objects-in-C

Thursday, 7 August 2014

system.data.oledb.oledbexception could not find installable isam


The path name should be like below:

string filename = "C:\\Praveen\\Tasks\\TASK 1\\Mydata.xlsx";
            MyOleCon = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+ filename +";Extended Properties=\"Excel 12.0 Xml;HDR=YES;\"");

Sunday, 8 June 2014

Creating Bootable Pen Drive Using Windows Command Prompt


I have used this links:



Making a pen drive bootable is possible in Windows7 & Windows8 operating system. Formatting a computer to install fresh Windows OS with a CD/DVD drive is not very good because it takes too much time to install fresh Windows operating system. There can also be a problem for many people that CD/DVD drive doesn’t work properly. So this can be a problem for them. Today laptop or desktop comes many USB ports. So there is no need of CD/DVD drive to format a system. Formatting is very fast and easy with flash drive/pen drive and also no software is required for this method. Windows7 or Windows8 command prompt can do the work with few lines of command. Just follow this tutorial.

Start your command prompt.
 For windows7 users:
1. Go to “Start” button and click. Write “cmd” then cmd icon will appear on the top of the panel.
2. “Right click” on the cmd icon and click “Run as administrator”
3. It will open the command prompt.





Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>diskpart

Microsoft DiskPart version 6.1.7601
Copyright (C) 1999-2008 Microsoft Corporation.
On computer: SUMAN

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          298 GB  1024 KB
  Disk 1    Online           14 GB      0 B

DISKPART> select disk 1

Disk 1 is now the selected disk.

DISKPART> clean

DiskPart succeeded in cleaning the disk.

DISKPART> create partition primary

DiskPart succeeded in creating the specified partition.

DISKPART> list partition 1

The arguments specified for this command are not valid.
For more information on the command type: HELP LIST PARTITION

DISKPART> list partition

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
* Partition 1    Primary             14 GB  1024 KB

DISKPART> select partition 1

Partition 1 is now the selected partition.

DISKPART> active

DiskPart marked the current partition as active.

DISKPART> format fs=ntfs

  100 percent completed

DiskPart successfully formatted the volume.

DISKPART> active

DiskPart marked the current partition as active.

DISKPART> exit

Leaving DiskPart...

C:\Windows\system32>

Friday, 30 May 2014

Design patterns

Skills needed for .Net experienced

Skills needed for .Net experienced
  • .Net Framework (2.0, 3.5)
  • ASP.NET (2.0)
  • C#/VB.NET
  • Object Oriented Programming
  • .NET IDE (2008)
  • Debug Tools (Fiddler, IE Dev tools, Firebug)
  • SQL Server 2K/2005/8
  • Oracle 11g
  • Web Services/WCF
  • AJAX
  • XML & XSL
  • HTML, CSS
  • Javascript
  • Jquery
  • JSON
  • Crystal Reports
  • Methodologies (AGILE Scrum)
  • VSS, SVN
  • IIS 6.0
  • Modelling Tools (Visio, Erwin)
  • Design Patterns
  • Frameworks(Entity, Spring, MVC)







.Net good materials links

This is the best video material links which is created by G venkat

C# and ASP.net and MVC and WCF.

http://www.pragimtech.com/c-sharp-video-tutorials.aspx


Discover the Design Patterns You're Already Using in the .NET Framework

Introducing Windows Communication Foundation in .NET Framework 4

Object-Oriented Programming (C# and Visual Basic)

Six important .NET concepts: Stack, heap, value types, reference types, boxing, and unboxing

A Guide to Designing and Building RESTful Web Services with WCF 3.5

Basic Security Practices for Web Applications

Building web apps without web forms

C# Tuterails link

.Net interview real time interview questions




Blog for the interview questions

http://computerauthor.blogspot.in/





sharepoint server 2007 meterial links

Wednesday, 9 April 2014

To find the used range of the rows in Excel using VBA

To find the used range of the rows and columns:

Set VillageDataSheet = Worksheets("Water Point Data")
-> NumPoints = VillageDataSheet.UsedRange.Rows.Count
-> NumPoints = VillageDataSheet.Range("A" & VillageDataSheet.Rows.Count).End(xlUp).Row


Tuesday, 25 March 2014

How to find the text column number using VBA


it will search the value and find the column number

m_BlocID_CLM = WorksheetFunction.Match("Bloc ID", ActiveWorkbook.Sheets("Data").Range("1:1"), 0)


it will return the value 1

Thursday, 13 February 2014

VBA function to convert column number to letter?


Function Col_Letter(lngCol As Long) As String

Dim vArr
vArr = Split(Cells(1, lngCol).Address(True, False), "$")
Col_Letter = vArr(0)
End Function

Sub Test()
MsgBox Col_Letter(100)
End Sub

Friday, 7 February 2014

AllowFormattingCells Property [Excel 2003 VBA Language Reference]

Sub ProtectionOptions()

    ActiveSheet.Unprotect

    ' Allow cells to be formatted on a protected worksheet.
    If ActiveSheet.Protection.AllowFormattingCells = False Then
        ActiveSheet.Protect AllowFormattingCells:=True
    End If

    MsgBox "Cells can be formatted on this protected worksheet."

End Sub

How to write the string(unicode) to textfile

Set fs = CreateObject("Scripting.FileSystemObject")

dlgSaveAsString = Application.GetSaveAsFilename("ABCD.txt", FileFilter:="text file (*.txt),*.txt")

If (dlgSaveAsString <> False) Then
    Set a = fs.CreateTextFile(dlgSaveAsString, True, True)
    a.writeline (kmlText)
    a.Close
End If

for more details: please check the below text and link

CreateTextFile Method
See Also    Example    Applies To    Specifics
Description
Creates a specified file name and returns a TextStream object that can be used to read from or write to the file.
Syntax
object.CreateTextFile(filename[, overwrite[, unicode]])
The CreateTextFile method has these parts:

Part
Description
object
Required. Always the name of a FileSystemObject or Folder object.
filename
Required. String expression that identifies the file to create.
overwrite
Optional. Boolean value that indicates if an existing file can be overwritten. The value is True if the file can be overwritten; False if it can't be overwritten. If omitted, existing files are not overwritten.
unicode
Optional. Boolean value that indicates whether the file is created as a Unicode or ASCII file. The value is True if the file is created as a Unicode file; False if it's created as an ASCII file. If omitted, an ASCII file is assumed.


http://msdn.microsoft.com/en-us/library/aa265018(v=vs.60).aspx

Tuesday, 21 January 2014

How to load excel data to Database using query




LOAD DATA LOCAL INFILE 'D:/MyWork/Master.csv' 
INTO TABLE Master COLUMNS TERMINATED BY ',';