Adds

Monday, 3 April 2017

Open AutoCAD & Send Command Using C#

private void Form1_Load(object sender, EventArgs e)
{           
string progID = "AutoCAD.Application.19";

AcadApplication acApp;
AcadApplication vAcadDoc;

if (Process.GetProcessesByName("acad").Length > 0)
{
acApp = (AcadApplication)Marshal.GetActiveObject(progID);
acApp.ActiveDocument.SendCommand("PURGE ");
}
else
{
acApp = new AcadApplication();
acApp = (AcadApplication)Marshal.GetActiveObject(progID);
acApp.ActiveDocument.SendCommand("PURGE ");
}                      
}


Thursday, 26 November 2015

Update Name to Title Case in SQL Server using SQL Query




-- User Define Function
Create Function dbo.[UDF_TITLE_CASE]
(
      @String VARCHAR(MAX)  -- Variable for string
)
RETURNS varchar(MAX)
BEGIN
     Declare @Xml XML
     Declare @ProperCase Varchar(Max)
     Declare @delimiter Varchar(5)
     Set @delimiter=' '
     SET @Xml = cast(('<A>'+replace(@String,@delimiter,'</A><A>')+'</A>') AS XML)

     ;With CTE AS (SELECT A.value('.', 'varchar(max)') as [Column]
      FROM @Xml.nodes('A') AS FN(A) )
      Select @ProperCase =Stuff((Select ' ' + UPPER(LEFT([Column],1))
      + LOWER(SUBSTRING([Column], 2 ,LEN([Column]))) from CTE
      for xml path('') ),1,1,'')

RETURN (@ProperCase)
END
GO
-- For Example :
SELECT dbo.[UDF_PROPER_CASE]([StudentInfo_Name]) as [Student Name]
from [dbo].[Tbl_StudentInformation]
GO

SELECT [StudentInfo_Name] as [Student Name]
from [dbo].[Tbl_StudentInformation]
GO


update [dbo].[Tbl_StudentInformation]
set [StudentInfo_Name]=dbo.[UDF_PROPER_CASE]([StudentInfo_Name])