Friday, 12 October 2012

ASP.NET Ajax framework failed to load client side framework

ASP.NET Ajax framework failed to load client side framework

 I face below errors at a same time.

ASP.Net Ajax framework failed to load client side framework
Microsoft JScript runtime error: 'Sys' is undefined
and Telerik is undefined.

If somebody else also got this error, below is what i did to resolve this error.
I had below in my web.config 

<add name="Telerik_Web_UI_WebResource_axd" path="Telerik.Web.UI.WebResource.axd"
                 type="Telerik.Web.UI.WebResource" verb="*"
                 preCondition="integratedMode,runtimeVersionv2.0"/>  


I removed runtimeversion2.0 and it worked well.

Just to update you that it was working well in IIS6.0 but error occured when i deploy it on IIS7.0

So the above entry was in <system.webServer> tag, which is basically for iis7 specific.

It took my lot of time to resolve this issue.

 

Wednesday, 3 October 2012

Basic LINQ Query





LINQ Queries



Basic LINQ Query Operators

From (Specify the Data Source)

In LINQ query first step is to specify the data source that you want to query.
Dim custdata = from  cust in customers
Filtering
Filtering the data. Query returns only those elements for which the expression is true.
Dim custdata = from  cust in customers                                            Where cust.city= “Delhi”
Ordering
Order by clause return the data in order which we asked for
Dim custdata = from  cust in customers                                            Where cust.city= “Delhi”
Order by cust.name ascending
Selecting
Select clause is used for specify the fields you want to incluse In the result.
Dim custdata = from  cust in customers                                            Where cust.city= “Delhi”
Order by cust.name ascending
Select cust.namr



LINQ Data Providers



LINQ Data Providers

The Following lists the core data types LINQ supports in the .Net Framework

Provider
Description
LINQ to Objects
The LINQ to Objects provider enables you to query in-memory collections and arrays. If an object supports either the IEnumerable or IEnumerable(Of T) interface, the LINQ to Objects provider enables you to query it.
You can enable the LINQ to Objects provider by importing the System.Linq namespace, which is imported by default for all Visual Basic projects.
LINQ to SQL
The LINQ to SQL provider enables you to query and modify data in a SQL Server database. This makes it easy to map the object model for an application to the tables and objects in a database.
Visual Basic makes it easier to work with LINQ to SQL by including the Object Relational Designer (O/R Designer). This designer is used to create an object model in an application that maps to objects in a database. The O/R Designer also provides functionality to map stored procedures and functions to the DataContext object, which manages communication with the database and stores state for optimistic concurrency checks.
System.data.Linq
LINQ to XML
The LINQ to XML provider enables you to query and modify XML. You can modify in-memory XML, or you can load XML from and save XML to a file.
LINQ to Dataset
The LINQ to Dataset provider enables you to query and update data in an ADO.NET dataset. You can add the power of LINQ to applications that use datasets in order to simplify and extend your capabilities for querying, aggregating, and updating the data in your dataset.
LINQ to Entities
This LINQ to Entities allows you to write queries against data modeled by using the Entity Framework.

Thursday, 16 August 2012

Sql Server Function Returns date in YYYYMMDD Format

Create FUNCTION [dbo].[fn_YMDDate]
(
      @dateParam     varchar(10)
)
RETURNS Varchar(10)
AS
BEGIN
      DECLARE @Return Varchar(10)

      Declare @YYYY  varchar(4)
      Declare @MM  varchar(2)
      Declare @DD  varchar(2)
      Declare @TMP varchar(2)
      Declare @strRemain  varchar(10)
      Declare @strSeprator  varchar(1)
      Declare @strOutPutSeprator  varchar(1)


      if  CHARINDEX ('/',@dateParam ,1)>0
            Begin
                  set @strSeprator='/'
            End
      Else
      if  CHARINDEX ('-',@dateParam ,1)>0
            Begin
                  set @strSeprator='-'
            End

      if  CHARINDEX ('.',@dateParam ,1)>0
            Begin
                  set @strSeprator='.'
            End           
       set @strOutPutSeprator = '.'    

      if  CHARINDEX (@strSeprator,@dateParam ,1)>0
            Begin
                  if  CHARINDEX (@strSeprator,@dateParam ,1) > 4 /*YYYY/MM/DD Format*/
                        Begin

                              set @YYYY=SUBSTRING(@dateParam,1 ,CHARINDEX(@strSeprator,@dateParam,1))
                              set @strRemain=SUBSTRING(@dateParam, CHARINDEX (@strSeprator,@dateParam,1)+1,len(@dateParam))
                              set @MM=SUBSTRING(@strRemain,1 ,(CHARINDEX(@strSeprator,@strRemain,1)-1))
                              set @DD=SUBSTRING(@strRemain, CHARINDEX (@strSeprator,@strRemain,1)+1,len(@strRemain))
                              IF CAST(@MM As int) > 12
                                BEGIN
                                    SET @TMP = @MM
                                    SET @MM = @DD
                                    SET @DD = @TMP
                                END

                        END
                  else
                        Begin
                              set @DD=SUBSTRING(@dateParam,1 ,(CHARINDEX (@strSeprator,@dateParam,1)-1))
                              set @strRemain=SUBSTRING(@dateParam, CHARINDEX (@strSeprator,@dateParam,1)+1,len(@dateParam))
                              set @MM=SUBSTRING(@strRemain,1,(CHARINDEX(@strSeprator,@strRemain,1)-1))
                              set @YYYY=SUBSTRING(@strRemain, CHARINDEX (@strSeprator,@strRemain,1)+1,len(@strRemain))

                              IF CAST(@MM As int) > 12
                                BEGIN
                                    SET @TMP = @MM
                                    SET @MM = @DD
                                    SET @DD = @TMP
                                END
                             
                        End

                        if len(@MM)=1
                       Begin
                              Set @MM='0'+@MM
                        End
                        if len(@DD)=1
                        Begin
                              Set @DD='0' +@DD
                        End

                        SET @Return =  @YYYY + @strOutPutSeprator + @MM + @strOutPutSeprator + @DD

     END
      RETURN ISNULL(@Return,'')
END

Tuesday, 24 July 2012

WCF Tutorial -Contracts


WCF-Contracts

WCF (Windows Foundation Communication) is a platform can be used to build service oriented applications.
We can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application. An endpoint can be a client of a service that requests data from a service endpoint. The messages can be as simple as a single character or word sent as XML, or as complex as a stream of binary data.

WCF has following core contracts

·         Service Contract
o    A service contract specifies the signature of a service, it defines the operations available to the service to be invoked, the data it exchanges, and other contractually required data
·         Operation Contract
o   Operation Contracts are the methods which are exposed in the service.
·         Data Contract
o   Defines the structure of the data included in the payloads of the messages flowing in and out of the service.
·         Message Contract
o   Enables you to control the headers that appears in the message and how the messages are structured.
·         Fault Contract
o   WCF enables you to specify the fault behavior of your service, when your service might issue faults and what type of information will be sent with the fault.


WCF Basics

Service.Servicemodel is the namespace to specify the behavior of WCF Service. While Defining WCF Service we have to take care of following aspects.

1.      How service behaves and what operations it exposes
2.      When service might issue faults and what kind of fault it might issue.
3.      What MEPs are required to interact with the service operations will be one-way two- way etc.


Three core types of WCF contracts map directly to a corresponding web service standard in the following way.

Service contract map to WSDSL
Data contract map to XSD
Message contract map to SOAP