Wednesday, December 14, 2016

MS Sql Basics I

MS Sql Basics I

Index



Tuesday, November 22, 2016

Sangam 16


AIOUG & My Journey to Sangam16

    I have been associated with All India Oracle User Group for more than a year now. Started the association with presenting a basic topic and gradually leading up the Bangalore Team of AIOUG.
It's always nice to share Knowledge and this group has got really nice folks who are eager to just share all that they know.

This was my first Sangam event, was not sure of how this event would go but the 3 days of it was one of the best 3 days of this year. What a good note to end the year.

Online & Offline efforts to promote the event. Sent almost 6600 emails, 130 phone calls, don't care how many of my efforts converted into actual registrant( we got 700+ attendees).

More than learning got to meet great Technical Geeks to making new friends.

Sangam16 can be better be presented as collection of photos.

        

Registration Way






Saturday, November 19, 2016

ALTER table - I

ALTER TABLE tbl_Name
ALTER Column Col_Name

This is one of the expensive activity in ms-sql.

<?query --
UPDATE [vcp].[dbo].[tbl_ClaimParser_AUDIT] SET [TPA_Number] = [TPA_Number]
--?>

Friday, September 16, 2016

Change Drive location of MS Sql

USE MASTER;
GO
-- Take database in single user mode -- if you are facing errors -- This may terminate your active transactions for database

ALTER DATABASE xxDBNamexx
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
GO
-- Detach DB
EXEC MASTER.dbo.sp_detach_db @dbname = N'TestDB' GO

Now move the files from loc1 to loc2. You can now reattach the files with new locations

-- Move MDF File from Loc1 to Loc 2
-- Re-Attached DB
CREATE DATABASE [TestDB] ON
( FILENAME = N'F:\loc2\TestDB.mdf' ),
( FILENAME = N'F:\loc2\TestDB_log.ldf' )
FOR ATTACH
GO

Tuesday, August 9, 2016

MVC

What is MVC ?
The Model-View-Controller (MVC) is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller. Each of these components are built to handle specific development aspects of an application.

                                               model_view_controller
Modal - Holds all data related code, ex. get data from view or DB or business logic.
View - UI
Controller - Acts an interface between Modal and View to process all business logic

Sunday, July 31, 2016

ASP.Net

ASP.Net




ASP.Net Events

Events in ASP.NET raised at the client machine, and handled at the server machine.

Syntax  private void EventName (object sender, EventArgs e);

Application and Session Events


  • Application_Start
  • Application_End
  • Session_Start
  • Session_End  

Page and Control Events 

Common page and control events are: 

  • DataBinding - It is raised when a control binds to a data source. 
  • Disposed - It is raised when the page or the control is released. 
  • Error - It is a page event, occurs when an un-handled exception is thrown. 
  • Init - It is raised when the page or the control is initialized.
  • Load - It is raised when the page or a control is loaded. 
  • PreRender - It is raised when the page or the control is to be rendered. 
  • Unload - It is raised when the page or control is unloaded from memory.
Event Handling Using Controls

 All ASP.NET controls are implemented as classes, and they have events which are fired when a user performs a certain action on them. For example, when a user clicks a button the 'Click' event is generated. For handling events, there are in-built attributes and event handlers. Event handler is coded to respond to an event, and take appropriate action on it.

<asp:Button ID="btnCancel" runat="server" Text="Cancel" />

The event handler for the Click event:

Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click 
End Sub

An event can also be coded without Handles clause.
<asp:Button ID="btnCancel" runat="server" Text="Cancel" Onclick="btnCancel_Click" />

The event handler for the Click event:
Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) End Sub

Postback vs Non-Postback events








ASP.Net Server Side

Page itself gets instantiated as control object. All web forms are instances of ASP.Net page class.

Server Object
Are instances of the System.Web.HttpServerUtility. 

PropertyDescription
MachineNameName of server computer
ScriptTimeOutGets and sets the request time-out value in seconds.
The following table provides a list of some important methods:
MethodDescription
CreateObject(String)Creates an instance of the COM object identified by its ProgID (Programmatic ID).
CreateObject(Type)Creates an instance of the COM object identified by its Type.
Equals(Object)Determines whether the specified Object is equal to the current Object.
Execute(String)Executes the handler for the specified virtual path in the context of the current request.
Execute(String, Boolean)Executes the handler for the specified virtual path in the context of the current request and specifies whether to clear the QueryString and Form collections.
GetLastErrorReturns the previous exception.
GetTypeGets the Type of the current instance.
HtmlEncodeChanges an ordinary string into a string with legal HTML characters.
HtmlDecodeConverts an Html string into an ordinary string.
ToStringReturns a String that represents the current Object.
Transfer(String)For the current request, terminates execution of the current page and starts execution of a new page by using the specified URL path of the page.
UrlDecodeConverts an URL string into an ordinary string.
UrlEncodeTokenWorks same as UrlEncode, but on a byte array that contains Base64-encoded data.
UrlDecodeTokenWorks same as UrlDecode, but on a byte array that contains Base64-encoded data.
MapPathReturn the physical path that corresponds to a specified virtual file path on the server.
TransferTransfers execution to another web page in the current application.
Request Object

Is an instance of System.Web.HttpRequest.
It represents the values and properties of HTTP Request that makes page loading into browser.

PropertyDescription
AcceptTypesGets a string array of client-supported MIME accept types.
ApplicationPathGets the ASP.NET application's virtual application root path on the server.
BrowserGets or sets information about the requesting client's browser capabilities.
ContentEncodingGets or sets the character set of the entity-body.
ContentLengthSpecifies the length, in bytes, of content sent by the client.
ContentTypeGets or sets the MIME content type of the incoming request.
CookiesGets a collection of cookies sent by the client.
FilePathGets the virtual path of the current request.
FilesGets the collection of files uploaded by the client, in multipart MIME format.
FormGets a collection of form variables.
HeadersGets a collection of HTTP headers.
HttpMethodGets the HTTP data transfer method (such as GET, POST, or HEAD) used by the client.
InputStreamGets the contents of the incoming HTTP entity body.
IsSecureConnectionGets a value indicating whether the HTTP connection uses secure sockets (that is, HTTPS).
QueryStringGets the collection of HTTP query string variables.
RawUrlGets the raw URL of the current request.
RequestTypeGets or sets the HTTP data transfer method (GET or POST) used by the client.
ServerVariablesGets a collection of Web server variables.
TotalBytesGets the number of bytes in the current input stream.
UrlGets information about the URL of the current request.
UrlReferrerGets information about the URL of the client's previous request that is linked to the current URL.
UserAgentGets the raw user agent string of the client browser.
UserHostAddressGets the IP host address of the remote client.
UserHostNameGets the DNS name of the remote client.
UserLanguagesGets a sorted string array of client language preferences.
The following table provides a list of some important methods:

MethodDescription
BinaryReadPerforms a binary read of a specified number of bytes from the current input stream.
Equals(Object)Determines whether the specified object is equal to the current object. (Inherited from object.)
GetTypeGets the Type of the current instance.
MapImageCoordinatesMaps an incoming image-field form parameter to appropriate x-coordinate and y-coordinate values.
MapPath(String)Maps the specified virtual path to a physical path.
SaveAsSaves an HTTP request to disk.
ToStringReturns a String that represents the current object.
ValidateInputCauses validation to occur for the collections accessed through the Cookies, Form, and QueryString properties.
Response Object

Represents server's response. It is an istance of System.Web.HttpResponse.

PropertyDescription
BufferGets or sets a value indicating whether to buffer the output and send it after the complete response is finished processing.
BufferOutputGets or sets a value indicating whether to buffer the output and send it after the complete page is finished processing.
CharsetGets or sets the HTTP character set of the output stream.
ContentEncodingGets or sets the HTTP character set of the output stream.
ContentTypeGets or sets the HTTP MIME type of the output stream.
CookiesGets the response cookie collection.
ExpiresGets or sets the number of minutes before a page cached on a browser expires.
ExpiresAbsoluteGets or sets the absolute date and time at which to remove cached information from the cache.
HeaderEncodingGets or sets an encoding object that represents the encoding for the current header output stream.
HeadersGets the collection of response headers.
IsClientConnectedGets a value indicating whether the client is still connected to the server.
OutputEnables output of text to the outgoing HTTP response stream.
OutputStreamEnables binary output to the outgoing HTTP content body.
RedirectLocationGets or sets the value of the Http Location header.
StatusSets the status line that is returned to the client.
StatusCodeGets or sets the HTTP status code of the output returned to the client.
StatusDescriptionGets or sets the HTTP status string of the output returned to the client.
SubStatusCodeGets or sets a value qualifying the status code of the response.
SuppressContentGets or sets a value indicating whether to send HTTP content to the client.
The following table provides a list of some important methods:
MethodDescription
AddHeaderAdds an HTTP header to the output stream. AddHeader is provided for compatibility with earlier versions of ASP.
AppendCookieInfrastructure adds an HTTP cookie to the intrinsic cookie collection.
AppendHeaderAdds an HTTP header to the output stream.
AppendToLogAdds custom log information to the InterNET Information Services (IIS) log file.
BinaryWriteWrites a string of binary characters to the HTTP output stream.
ClearContentClears all content output from the buffer stream.
CloseCloses the socket connection to a client.
EndSends all currently buffered output to the client, stops execution of the page, and raises the EndRequest event.
Equals(Object)Determines whether the specified object is equal to the current object.
FlushSends all currently buffered output to the client.
GetTypeGets the Type of the current instance.
PicsAppends a HTTP PICS-Label header to the output stream.
Redirect(String)Redirects a request to a new URL and specifies the new URL.
Redirect(String, Boolean)Redirects a client to a new URL. Specifies the new URL and whether execution of the current page should terminate.
SetCookieUpdates an existing cookie in the cookie collection.
ToStringReturns a String that represents the current Object.
TransmitFile(String)Writes the specified file directly to an HTTP response output stream, without buffering it in memory.
Write(Char)Writes a character to an HTTP response output stream.
Write(Object)Writes an object to an HTTP response stream.
Write(String)Writes a string to an HTTP response output stream.
WriteFile(String)Writes the contents of the specified file directly to an HTTP response output stream as a file block.
WriteFile(String, Boolean)Writes the contents of the specified file directly to an HTTP response output stream as a memory block.

HTML Server Control

HTML server controls are basic html controls enhanced to enable server side processing. They are not processed by servers instead they are sent to browser for display.

They are specifically converted to server control by adding runat="server" tag and an ID attribute.

Client Side

1. Client side scripting - Code that runs on browser and are not sent to server for processing.

2. Client side code - This is code behind of aspx. Contains number of hidden field to handle view state etc.

Basic Controls


.

Friday, May 6, 2016

WCF Part 7 : WCF Binding










WCF Part 6 : WCF Hosting

WCF Hosting


  • IIS Hosting
  • Self Hosting
  • WAS Hosting
  • Windows Service Hosting
IIS Hosting

  • Advantage of hosting a service in IIS
  • Automatically launches the host process when it gets first client request.
  • Uses features of IIS like Process Recycling, Idle shutdown, Process health monitoring, Message based activation
Disadvantage
  • Only Supports HTTP Protocol
Tips : While creating service , choose Http as location in VS new project.

Self Hosting

We make a Host service, keep it running and another application as client which consumes service. It can be any application like console or win form.

Windows Activation Hosting

It is available with windows vista and above. It is available with IIS7.0 and supports Http, TCP and named Pipes.
Hosting WCF in Activation service takes many advantages such as process recycling, isolation, idle time management and common configuration system. WAS hosted service can be created using following steps Enable WCF for non-http protocols Create WAS hosted service Enable different binding to the hosted service

Wednesday, May 4, 2016

WCF Part 5 - Architecture


Architecture

   


Contracts

Contracts layer are next to that of Application layer. Developer will directly use this contract to develop the service.

Service contracts

Describes about the operation that service can provide. 
Example, Service provided to know the temperature of the city . It will be created using Service and Operational Contract attribute.

Data contract

It describes the custom data type which is exposed to the client. This defines the data types, are passed to and from service. 

Message Contract

Default SOAP message format is provided by the WCF runtime for communication between Client and service. If it is not meeting your requirements then we can create our own message format. This can be achieved by using Message Contract attribute.

Policies and Binding

Specify conditions required to communicate with a service e.g security requirement to communicate with service, protocol and encoding used for binding.

Service Run-time

- It contains the behaviors that occur during runtime of service.
  • Throttling Behavior- Controls how many messages are processed.
  • Error Behavior - Specifies what occurs, when internal error occurs on the service.
  • Metadata Behavior - Tells how and whether metadata is available to outside world.
  • Instance Behavior - Specifies how many instance of the service has to be created while running.
  • Transaction Behavior - Enables the rollback of transacted operations if a failure occurs.
  • Dispatch Behavior - Controls how a message is processed by the WCF Infrastructure.

Messaging

- Messaging layer is composed of channels. A channel is a component that processes a message in some way, for example, by authenticating a message. A set of channels is also known as a channel stack. Channels are the core abstraction for sending message to and receiving message from an Endpoint. Broadly we can categories channels as
  • Transport Channels
    Handles sending and receiving message from network. Protocols like HTTP, TCP, name pipes and MSMQ.
  • Protocol Channels
    Implements SOAP based protocol by processing and possibly modifying message. E.g. WS-Security and WS-Reliability.

Activation and Hosting

- Services can be hosted or executed, so that it will be available to everyone accessing from the client. WCF service can be hosted by following mechanism
  • IIS
    Internet information Service provides number of advantages if a Service uses Http as protocol. It does not require Host code to activate the service, it automatically activates service code.
  • Windows Activation Service
    (WAS) is the new process activation mechanism that ships with IIS 7.0. In addition to HTTP based communication, WCF can also use WAS to provide message-based activation over other protocols, such as TCP and named pipes.
  • Self-Hosting
    WCF service can be self hosted as console application, Win Forms or WPF application with graphical UI.
  • Windows Service
    WCF can also be hosted as a Windows Service, so that it is under control of the Service Control Manager (SCM).