Nov 26, 2013

getjson cross domain Examples using controller



getJson using is very simple calling client side.

Support Js file:
    1.jquery-1.7.1.intellisense.js
    2.jquery-1.7.1.js
    3.jquery-1.7.1.min.js

Examples:

Clients side:

without parameter :

 $.getJSON('../AssetController /BankHolder' , function (data) {
                         

                         $.each(data, function (i, items) {
                            
                         });
                     });
 With parameter:

var Datamain=1;
  $.getJSON('../AssetController /BankHolder'+Datamain , function (data) {
                         

                         $.each(data, function (i, items) {
                            
                         });
                     });


Controller:

Controllername:AssetController
 Method name:BankHolder

without parameter :

 public JsonResult BankHolder()
        {

            MVCSampleAppEntities context = new MVCSampleAppEntities();
            BankTrx model = new BankTrx();

            List<BankTrx> OpnmIBAN = context.Banks.Select(x => new BankTrx { BankId = x.BankId, BankName = x.BankName }).ToList();
            return Json(OpnmIBAN, JsonRequestBehavior.AllowGet);

        }
With Parameter :

 public JsonResult BankHolder(long id)
        {

            MVCSampleAppEntities context = new MVCSampleAppEntities();
            BankTrx model = new BankTrx();

            List<BankTrx> OpnmIBAN = context.Banks.Select(x => new BankTrx { BankId = x.BankId, BankName = x.BankName }).ToList();
            return Json(OpnmIBAN, JsonRequestBehavior.AllowGet);

        }




Jul 21, 2013

What is the Maximum Relational Database Size Supported by Single Instance?

What is the Maximum Relational Database Size Supported by Single Instance?

 

 

The SQL Server 2008R2, 2012 and 2014 has maximum capacity of 524 PB (Pet byte) in the Enterprise, BI and Standard edition.

     SQL Server Express has a limitation of 10 GB due to its nature.
     It is all depending on the size of your storage system.
 

 

 

Jul 18, 2013

ClientID Mode in asp.net



ClientID Mode:

Client ID mode property can be used ID generate using Master page. While master page using content place holder used a controls the generate id is different so some confusing .The can used ClientID mode.

We can set ClientIDmode three ways the below following:

1. Application Level
2. PageLevel
3. Control Level


Application Level

We can use web.config file to set <System.Web> inside.

Example

 <pages clientIDMode="Predictable"></pages>
 

PageLevel:


<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WINDOWS8._Default"  ClientIDMode="AutoID"%>
 
 
Control Level

<asp:Button ID="btn_Add" runat="server” Text="ClickME" ClientIDMode="AutoID" />



ClientIDMode=" Static/AutoID/Inherit/Predictable/  
 
Static:
 
<asp: Button ID="btn_Add" runat="server Text="ClickMe" ClientIDMode="Static
 "/>
 
OUTPUT:
 
<input type="submit" name="ctl00$MainContent$btn_Add" value="ClickME" id="btn_Add" />
 
AutoID:
 
<asp:Button ID="btn_Add" runat="server” Text="ClickME" ClientIDMode="AutoID"/>
 
 
OUTPUT:
 
<input type="submit" name="ctl00$MainContent$btn_Add" value="ClickME" id="ctl00_MainContent_btn_Add" />
 
Inherit:
 
<asp:Button ID="btn_Add" runat="server"  Text="ClickME" ClientIDMode="Inherit"/>
 
 
Output:
 
<input type="submit" name="ctl00$MainContent$btn_Add" value="ClickME" id="MainContent_btn_Add" />
 
 
 
Predictable:

Predictable is the important mode of the Client ID Mode and it is mainly used for controls that are in data-bound controls.We can generate the ClientID value by concatenating the ClientID value of the parent naming container with the ID value of the current control.ClientIDRowSuffix is a property of the control which can be added at the end of a databound control that generates the multiple rows.Best example is the GridView Control where multiple data fileds can be specified and if the ClientIDRowSuffix property is blank then it will automatically add a sequential number at the end of the databound control id.This number begins at zero and is incremented by 1 for each row and each segment is separated by an underscore character (_).

Given below examples demonstrate how the databound control id renders in both the case(without ClientIDRowSuffix and with ClientIDRowSuffix )

<asp:GridView ID="Maxmun" runat="server" AutoGenerateColumns="false" ClientIDMode="Predictable" >
    <Columns>
        <asp:TemplateField HeaderText="ID">
            <ItemTemplate>
         <asp:Label ID="lblID" runat="server" Text='<%# Eval("ID") %>' />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Name">
            <ItemTemplate>
      <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>' />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Company Name">
            <ItemTemplate>
                <asp:Label ID="lblOrganisation" runat="server" Text='<%# Eval("CompName") %>' />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

Note:  ClientIDRowSuffix is blank by default in the above gridview declaration and just follow the given below syntax for adding the ClientIDRowSuffix in the gridview declaration

<asp:GridView ID="Maxmun" runat="server" AutoGenerateColumns="false" ClientIDMode="Predictable" ClientIDRowSuffix="ID" >
   

Output without ClientIDRowSuffix
 
<table id="Maxmun" style="border-collapse: collapse" cellspacing="0" rules="all" border="1">
    <tbody>
        <tr>
            <th scope="col">ID</th>
            <th scope="col">Name</th>
            <th scope="col">Company Name</th>
        </tr>
        <tr>
            <td><span id="Maxmun_lblID_0">001</span></td>
            <td><span id="Maxmun_lblName_0">Srikanta</span></td>
            <td><span id="Maxmun_lblOrganisation_0">Coimbatore</span></td>
        </tr>
        <tr>
            <td><span id="Maxmun_lblID_1">007</span></td>
            <td><span id="Maxmun_lblName_1">Kaushik</span></td>
             <td><span id="Maxmun_lblOrganisation_1">Coimbatore</span></td>
        </tr>
        .........
        .........
    </tbody>
</table>

Output with ClientIDRowSuffix
 

<table id="Maxmun" style="border-collapse: collapse" cellspacing="0" rules="all" border="1">
    <tbody>
        <tr>
            <th scope="col">ID</th>
            <th scope="col">Name</th>
            <th scope="col">Company Name</th>
        </tr>
        <tr>
            <td><span id="Maxmun_lblID_001">001</span></td>
            <td><span id="Maxmun_lblName_001">Srikanta</span></td>
            <td><span id="Maxmun_lblOrganisation_001">Coimbatore</span></td>
        </tr>
        <tr>
            <td><span id="Maxmun_lblID_007">007</span></td>
            <td><span id="Maxmun_lblName_007">Kaushik</span></td>
             <td><span id="Maxmun_lblOrganisation_007">Coimbatore</span></td>
        </tr>
        ......
    </tbody>
</table>









Squence Query in SQL SERVER



Select Squence Query in SQL SERVER :


-It can be used Automatic Generation number without column in the table can use Sequence concept.

 

select      (
      ROW_NUMBER()
      over (Order by EmpId))as Rownumber,
      EmpId,
      EmpName,
      EmpSalary  

      from Sequence_Tbl

Quotename() function in SQL Server

 

Quotename() function in SQL Server :

It can be used strongly string in sqlserver, the string valid return values.

Examples

select quotename('munish')   --[munish]
 
select quotename('munish [ars]') -- [munish [ars]]]
 
select quotename('munish ars', '"') -- "munish ars"
 
select quotename('munish ars''s Name', '''') -- 'munish ars''s Name'
 
select quotename('munish ars', '''') -- 'munish ars'
 
select quotename('Pravin More', '|') – NULL

Jul 14, 2013

Authorization set some page or folder in web.config in Asp.net

 

Authorization set some page or folder in web.config in Asp.net

The authentication set  to some page only allowed public page and other page only private page .How can developing these are things, Its very easy to change Web.config file let us see…


 <authentication mode="Windows/Forms ">

 <authorization>
         <deny users="*"/>
  </authorization>
 
Now I wrote the Web.config file all page restrict the browser the project the Below Error.
 

Access is denied.

Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.
 
IF you have changed the some page only allowed public Access to use to below source code.
 
Page Level
 
<location path="TestAuth.Aspx">
    <system.web>
      <authorization >
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>
 
Folder Level:
  
If you have using Folder Authentication Account used the below code.
 
<location path="Account">
    <system.web>
      <authorization >
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>
 
The Authorization using
   -> User 
   -> Roles 
 
 <allow users="*"/> -The Allow to user view the page everyone,
 <allow Roles="*"/> -The Allow to Roles view the page everyone,
  
  <allow Roles="Admin, Customer"/> -The Allow to Roles view the page Admin an d customer,
 
 
Deny Anonymous user to access entire website
This is the case when you want everybody to login before the can start browsing around your website. i.e. The first thing they will see is a login page.
  <system.web>
    <authentication mode="Forms">
    </authentication>
    <authorization>
      <deny users="?"/> //will deny anonymous users
    </authorization>
  </system.web>
Images and CSS files
Say you have all your images and CSS in a seperate folder called images and you are denying anonymous access to your website. In that case you might see that on your login page you cannot see images(if any) and css(if any) applied to your login page controls.
In that case you can add a web.config to the images and css folder and allow access to everyone to that folder. So your web.config in images folder should look as below:
<configuration>
    <system.web>
      <authorization>
        <allow users="*"/> //Allow everyone
      </authorization>
    </system.web>
  </configuration>

Common Mistakes
I have seen people complaining that they have setup their roles correctly and also made entry to their web.config but still their authorization doesn't work. Even they have allowed access to their role that user cannot access particular page/folder. The common reason for that is placing <deny../> before <allow ../>.
Say the web.config from AdminFolder as we have seen before is something like this:
 //This web.config will not allow access to users even they are in Admin Role
  <configuration>
    <system.web>
      <authorization>
        <deny users="*"/> // deny everyone else
        <allow roles="Admin"/> //Allows users in Admin role
      </authorization>
    </system.web>
  </configuration>

 
Resources:
http://weblogs.asp.net/gurusarkar/archive/2008/09/29/setting-authorization-rules-for-a-particular-page-or-folder-in-web-config.aspx
 
 
 






Jul 11, 2013

Default Constraint

 Default Constraint


 -it can be used default value to insert in the column


 Example 1:


 create table Person(id int,city varchar(20) Default 'INDIA')

 insert into Person values(1,default)

 select * from Person

 Example 2:


 create table PerDate(id int,Date Date Default getdate())

 insert into PerDate Values(1,Default)

 select * from PerDate


check constraint

check constraint

-it can be used limiting by values are accepted one more values.
-it can be used any logical values expression and true or false logical operators.
-CHECK constraints reject values that evaluate to FALSE. Because null values the Database Engine inserts NULL and does not return an error.

Check Constraint:


 CREATE TABLE Test(Id int  constraint Ck_ID check (LEN(ID)=1))

 INSERT INTO Test values(null)

 (1 row(s) affected)

 

 Function Using Check Constraint:


 CREATE TABLE Test2 (ID1 int, ID2 int);

 CREATE FUNCTION CheckingFun()
 RETURNS int
 AS
 BEGIN
 DECLARE @val int
 SELECT  @val=COUNT(*) from Test2
 RETURN  @val
 END;

 ALTER TABLE Test2 ADD CONSTRAINT CH_ID CHECK(dbo.CheckingFun()>=1)

 INSERT INTO Test2 Values(10,10)

 (1 row(s) affected)

Jul 10, 2013

Identity in SQL server

Identity:

Creates an identity column in a table. This property is used with the CREATE TABLE in increment values.

IDENTITY [ (seed , increment) ]

It can be used identity values to off or on.

SET IDENTITY_INSERT Test on

SET IDENTITY_INSERT Test on

 create table Test(Id int identity(1,1))
 insert into Test  DEFAULT VALUES

 create table Test1(Id int identity(1,1))
 alter table Test Add name varchar(20)
 insert into Test (name)values('munish')




DBCC CHECKIDENT

DBCC CHECKIDENT (Test, RESEED, 0)
DBCC CHECKIDENT (Test, NORESEED)


Jun 12, 2013

How to create GUID in C# use Asp.net:





Explain GUID:
   GUID is Global unique identifier it can be used namespace
    Using System;
 
Assemble name is: mscorlib.dll
 
Examples:
 
Property method:
 
    public Guid ID { get; set; }   
 
Public Guid ID ()
{
   Guid EmployeeID;
   EmployeeID=Guid.NewGuid();
   Response.write(EmployeeID);
   Response.write(Guid.NewGuid());
} 
 
Output:
 
0f8fad5b-d9cb-469f-a165-70867728950e
7c9e6679-7425-40de-944b-e07fc1f90ae7
 

Apr 24, 2013

Asp.net Connection String Performance Optimization:



Asp.net Connection String Performance Optimization: 
 
Introduction:
   Most ADO.NET data providers use connection pooling to improve the performance of applications built around Microsoft's disconnected .NET architecture. An application opens a connection (or gets a connection handle from the pool), runs one or more queries, processes the row set, and releases the connection back to the pool. Without connection pooling, these applications would spend a lot of additional time opening and closing connections.
When you use ADO.NET connection pooling to manage connections for your Web-based applications and client/server Web service applications, your customers will usually get faster connections and better overall performance. But what happens when your application or Web site is suddenly flooded with customers who all want to connect at the same time? Will your applications sink or swim? Like a lifeguard, you need to monitor your connection pools carefully to maintain good performance and to prevent your pools from overflowing. Let's explore the reasons a connection pool might overflow, and then see how you can write code or use Windows Performance Monitor to monitor your pools.
These are ways to following the connection string in your application some of avoid the discomfort and increase performance better in your application.
     Your check status in your mssql server Process .we were open the connection data provider  .net framework using sqlserver means in display program name “.Net SqlClient Data Provider “   and  also display the waiting time .
 
SELECT SPID,STATUS,waittime,PROGRAM_NAME,LOGINAME=RTRIM(LOGINAME),HOSTNAME,CMD FROM  MASTER.DBO.SYSPROCESSES 
 
once the connectio open to exiting the process status by sleeping.



 
 
SELECT SPID,STATUS,waittime,PROGRAM_NAME,LOGINAME=RTRIM(LOGINAME),HOSTNAME,CMD FROM  MASTER.DBO.SYSPROCESSES where Status='runnable'
 
If you have to execute query using Sql query Editor to display status by runnable.
 
 
Otherwise to execute System Store procedure:
 
EXEC SP_WHO
 
 
 
Pooling:



Pooling Architecture:
 
 
Connection string pooling to Controlling properties:
1.      Pooling 
2.      Packet Size
3.      Min Pool Size
4.      Max Pool Size
5.      Connection Life Time 
6.      Connection Timeout 
7.      Enlist
8.      Increase the Pool Size
9.      Decrease the  Pool size
 
Sample Connection String Controlling pooling:
 
<add name="LocalSqlServer" connectionString="Data Source=************;Persist Security Info=True;User Id=****;Password=*******;Initial CataLog=*******;Trusted_Connection=False;Pooling=True;Max Pool size=100;Min pool size=0;Packet Size=512;Connection Timeout=0"  />
 
1. Pooling:
   
Introduction:
 
.net framework pages Connection through the database improving the performance to use and Polling Concept. A connection container of open the pool reusable connection. When the connection to open to use a pool memory .when last connection is closed the database other pool can used. The main disadvantage is that one or more database connections, even if they are currently not being used, are kept open. The Data Providers in ADO.NET have Connection Pooling turned on by default; if you need to turn it off, specify Pooling = false in the connection string being used. Connection Pooling gives you an idle, open, reusable connection instead of opening a new one every time a connection request to the database is made. When the connection is closed or disposed, it is returned to the pool and remains idle until a request for a new connection comes in. If we use Connection Pooling efficiently, opening and closing of connections to the database becomes less resource expensive. This article discusses what Connection Pooling is all about and how Connection Pooling can be used efficiently to boost the performance and scalability of applications.
 
The Default Pool is: Pooling=True;
 
When pooling to true. The SQLConnection object is drawn from the appropriate pool, or if it is required, is created and added to the appropriate pool to false.  
 
2. Packet Size:
 
The Default Packet Size is: Packet Size =512;
Packet Size may be a value in the range of 512 and 32767 bytes. An exception is generated if the value is outside this range.
Setting the default value to a number greater than 8000 will cause the packets to use the MultiPage allocator on the instance of SQL Server instead of the much more efficient SinglePage allocator, reducing the overall scalability of the SQL Server.
3. Minimum Pool Size:
 
    The Default Minimum Pool Size is: Min Pool Size =0;
 
   The minimum number of connections allowed in the pool.
 
4. Maximum Pool Size:
 
     The Default Maximum Pool Size is:  Max Pool Size=100;
     The Maximum Pool Size is depends upon the Server Configuration. The Maximum    number of Connection allowed in the pool configuration.
 
5. Connection Life Time:
The Default Connection Life time is:  Connection LifeTime =0;
 
When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time seconds. The value specified by Connection Lifetime. A value of zero causes pooled connections to have the maximum connection timeout.
 
6. Connection Timeout:
 
The Default Connection TimeOut is:  Connection TimeOut =15;
 
Maximum Time (in secs) to wait for a free connection from the pool
 
7. Enlist:
 
The Default Enlist: Enlist=True;
 
When Enlist   true means Pooler automatically enlists the connection in the creation thread's current transaction context. Recognized values to use Set Enlist = "false" to ensure that connection is not context specific.
 
8. Increase the Pool Size:
 
The Default Increase pool size: Incr Pool Size=5;
 
Controls the number of connections that are established when all the connections are used.
 
9. Decrease the Pool size:
 
The Default Decrease pool size: Decr Pool Size=1;
 
Controls the number of connections that are closed when an excessive amount of established connections are unused.
 

 
 
 
 
 
 
 
 

Recent Posts
Popular Articles

 

© 2013 MUNISH ORACLE DBA& .Net Developer. All rights resevered. Designed by Templateism

Back To Top