Sunday, June 3, 2018


Private Sub btnAccounts_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAccounts.Click
        Dim AccPath As String
        Dim arc(3) As String
        arc(0) = "Ravi"
        arc(1) = "1234"
        arc(2) = "he"
        AccPath = My.Application.Info.DirectoryPath
        Process.Start(AccPath & "\Accounts.exe", String.Format("{0} {1} {2}", arc(0), arc(1), arc(2)))
    End Sub
Base UserControl without XAML in WPF

public class BaseName : UserControl
{
    public BaseName()
    {
     
    }

}


<control:BaseName x:class=""   xlns:x="clr-namespace/<control library path>

Note : Base class should not be abstract if name is required in the child class, 

Bind data to combobox in Android

Bind data to combobox in Android

Note : Spinner is combobox control in android. 

Spinner spinnerBox = (Spinner) findViewById(R.Id.spinner_box);
ArrayAdapter<Employees> adapterEmp = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, empolyees);
adapterEmp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerBox.setAdapter(adapterEmp);


Monday, October 10, 2016

SharedSizeGroup in WPF

SharedSizeGroup in WPF

Share same column or row size across multiple grids in wpf.

<Grid Grid.IsSharedSizeScope="True">
   <Grid>
       <Grid.ColumnDefinitions>
           <ColumnDefinition Width="Auto" SharedSizeGroup="Name"/>
           <ColumnDefinition Width="Auto" SharedSizeGroup="Value"/>
       </Grid.ColumnDefinitions>
      <Label Grid.Column=0/>
      <Label Grid.Column=1/>
   </Grid>
   <Grid>
       <Grid.ColumnDefinitions>
           <ColumnDefinition Width="Auto" SharedSizeGroup="Name"/>
           <ColumnDefinition Width="Auto" SharedSizeGroup="Value"/>
       </Grid.ColumnDefinitions>
      <Label Grid.Column=0/>
      <Label Grid.Column=1/>
   </Grid>
</Grid>


The size of columns of both grid is shared each other even that is set through dynamically.

Listen Dependency Property is Changed without event in WPF

Listen Dependency Property is Changed without event in WPF

You wanna listen any dependency property of any object is changed without event or which does not have event,  here we go,

DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(TextBox.IsFocusedProperty,  typeof(TextBox));

dpd.AddValueChanged(txtName, (s, e)=>
{
     if(txtName.IsFocused)
                MessageBox.Show("Focused");

});

Wednesday, March 7, 2012

Getting All Date Format in Sql Server

Getting All Date Format in Sql Server 

DECLARE @Count INT
SELECT @Count=0

WHILE @Count<=500 

BEGIN 
      BEGIN TRY 
         IF CONVERT(NVARCHAR(50),GETDATE(),@Count)<>'0'
         BEGIN
             PRINT CONVERT(NVARCHAR(10),@Count) + ' - ' +                           CONVERT(NVARCHAR(50),GETDATE(),@Count)
         END
      END TRY
      BEGIN CATCH

      END CATCH
      SELECT @Count = @Count+1
END

Thursday, December 8, 2011

Creating Linked Server through Query in SQL Server

Creating Linked Server through Query in SQL Server


-- DROPPING IF EXISTS
IF  EXISTS (SELECT srv.name FROM sys.servers srv WHERE srv.server_id != 0
                                                                                      AND srv.name =@ServerName)
BEGIN
            EXEC master.dbo.sp_dropserver @server=@ServerName, @droplogins='droplogins'
END

-- CREATING LINKED SERVERS
EXEC master.dbo.sp_addlinkedserver @server = @ServerName, @srvproduct=N'SQL Server'

--The linked server remote logins
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=@ServerName,@useself=N'False',@locallogin=NULL,@rmtuser=@UserID,@rmtpassword=@Pwd
--GO

EXEC master.dbo.sp_serveroption @server=@ServerName, @optname=N'collation compatible',           
                                                                                                                    @optvalue=N'false'
 --GO

 EXEC master.dbo.sp_serveroption @server=@ServerName, @optname=N'data access', 
                                                                                                                  @optvalue=N'true'
 --GO

 EXEC master.dbo.sp_serveroption @server=@ServerName, @optname=N'dist', @optvalue=N'false'
 --GO

 EXEC master.dbo.sp_serveroption @server=@ServerName, @optname=N'pub', @optvalue=N'false'
 --GO

 EXEC master.dbo.sp_serveroption @server=@ServerName, @optname=N'rpc', @optvalue=N'true'
 --GO

 EXEC master.dbo.sp_serveroption @server=@ServerName, @optname=N'rpc out', @optvalue=N'true'
 --GO

 EXEC master.dbo.sp_serveroption @server=@ServerName, @optname=N'sub', @optvalue=N'false'
 --GO

 EXEC master.dbo.sp_serveroption @server=@ServerName, @optname=N'connect timeout',       
                                                                                                @optvalue=N'0'
 --GO

 EXEC master.dbo.sp_serveroption @server=@ServerName, @optname=N'collation name',
                                                                                                @optvalue=null
 --GO

 EXEC master.dbo.sp_serveroption @server=@ServerName, @optname=N'lazy schema validation',
                                                                                                @optvalue=N'false'
--GO

EXEC master.dbo.sp_serveroption @server=@ServerName, @optname=N'query timeout',
                                                                                               @optvalue=N'0'
--GO

EXEC master.dbo.sp_serveroption @server=@ServerName, @optname=N'use remote collation', 
                                                                                               @optvalue=N'true'
--GO

EXEC master.dbo.sp_serveroption @server=@ServerName,
                                                      @optname=N'remote proc transaction promotion', @optvalue=N'true'
--GO