Tuesday, 18 February 2014

Bind DropDownList with SQL Server Data using .ajax() jQuery Method and Web Service

Hi readers,
Earlier I explained Binding DropDownList with jQuery and Wcf service. Now I am going to explain DropDownList with jQuery and web service. To Bind DropDownList in jQuery We have to write below code in

Use of DDL Trigger in SQL Server

The solution creates a DDL trigger that executes when CREATE TABLE and DROP TABLE DDL statements are executed and logs the events to a table named Log.
 
The solution uses a single table named Log. Execute the following T-SQL statement to create the table:
CREATE TABLE Log
(
   LogID int IDENTITY(1,1) NOT NULL,
   LogEntry varchar(max) NOT NULL,
   CONSTRAINT PK_Log PRIMARY KEY CLUSTERED
       ( LogID ASC )
)
Follow the below steps - 
  1. Create a new SQL Server project in Visual Studio and name it ClrDdlTrigger.
  2. Create a trigger item in the project. Name the item LogTableActivityTrigger.cs.
The C# code in LogTableActivityTrigger.cs in the project ClrDdlTrigger
* File: LogTableActivityTrigger.cs
Code View
using System;
using System.Data;
using
 System.Data.SqlClient;
using
 Microsoft.SqlServer.Server; 

public partial class Triggers
{
    public static void LogTableActivityTrigger()
    {
        SqlTriggerContext tc = SqlContext.TriggerContext;
        using (SqlConnection conn = new SqlConnection("context connection=true"))
        {
            conn.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn; 
   
            if (tc.TriggerAction == TriggerAction.CreateTable ||
                tc.TriggerAction == TriggerAction.DropTable)
            {
                cmd.CommandText = "INSERT INTO Log VALUES " +
                    "('" + tc.EventData.Value + "')";
                cmd.ExecuteNonQuery();
            }
        }
    }
}
 

A single DDL trigger is defined in the Triggers class. The trigger checks the TriggerAction property of the SqlTriggerContext and then logs the EventData for the event that caused this trigger to fire. In this example, it is not necessary to check the trigger context, as all events for which the trigger is registered execute the same code to log the event. You could use the TriggerAction property to perform different actions for each of the different events that a DDL trigger is registered to handle.
Build the solution.
Register the assembly and create the aggregate function by executing the following T-SQL statement in SQL Server Management Studio, replacing appropriately:
CREATE ASSEMBLY ClrDdlTrigger
FROM '\ClrDdlTrigger\bin\Debug\ClrDdlTrigger.dll'
GO
CREATE TRIGGER LogTableActivityTrigger
ON DATABASE
FOR CREATE_TABLE, DROP_TABLE
AS
EXTERNAL NAME ClrDdlTrigger.Triggers.LogTableActivityTrigger
Execute the following T-SQL statement to create and then drop a table named TestTable to demonstrate the DDL trigger:
CREATE TABLE TestTable
(
    TestID int NOT NULL,
    CONSTRAINT PK_TestTable PRIMARY KEY CLUSTERED
    ( TestID ASC )
)
GO
DROP TABLE TestTable
GO
* The Log table that now contains two rows detailing the DDL CREATE_TABLE and DROP_TABLE events.
* Log table LogID LogEntry 
Code View
   1<EVENT_INSTANCE>   <EventType>CREATE_TABLE</EventType>    <PostTime>2007-11-03T17:25:45.407</PostTime>    <SPID>52</SPID>    <ServerName>CTSUSNJY9779A</ServerName>    <LoginName>CTSUSNJY9779A\bill</LoginName>    <UserName>dbo</UserName>    <DatabaseName>AdoDotNet35Cookbook</DatabaseName>
|
    <SchemaName>dbo</SchemaName>

   <ObjectName>TestTable</ObjectName>    <ObjectType>TABLE</ObjectType>    <TSQLCommand>        <SetOptions ANSI_NULLS="ON" ANSI_NULL_DEFAULT="ON"        ANSI_PADDING="ON" QUOTED_IDENTIFIER="ON"        ENCRYPTED="FALSE" />       <CommandText>           CREATE TABLE TestTable
           (
             TestID int NOT NULL,
             CONSTRAINT PK_TestTable PRIMARY KEY CLUSTERED
             ( TestID ASC )
            )         
    </CommandText>      </TSQLCommand>
</
EVENT_INSTANCE> 
<EVENT_INSTANCE>    <EventType>DROP_TABLE</EventType>    <PostTime>2007-11-03T17:25:45.827</PostTime>    <SPID>52</SPID>    <ServerName>CTSUSNJY9779A</ServerName>    <LoginName>CTSUSNJY9779A\bill</LoginName>    <UserName>dbo</UserName>    <DatabaseName>AdoDotNet35Cookbook</DatabaseName>    <SchemaName>dbo</SchemaName>    <ObjectName>TestTable</ObjectName>    <ObjectType>TABLE</ObjectType>    <TSQLCommand>        <SetOptions ANSI_NULLS="ON" ANSI_NULL_DEFAULT="ON"        ANSI_PADDING="ON" QUOTED_IDENTIFIER="ON"        ENCRYPTED="FALSE" />        <CommandText>DROP TABLE TestTable</CommandText>        </TSQLCommand>
</
EVENT_INSTANCE>  

How to Enable/Disable clr in Sql server

Today I am going to explain very important feature of sql server 2008. Now we have an option 
for Enable/Disable of CLR .

We can prevent any DDL(CREATE/DROP) operation in sql server database Just the help of this option.

sp_configure 'clr enabled', 0
GO
RECONFIGURE
GO

run above code in sql query window.From this query we can disable clr. Now run,

create table test
(
abc varchar(10)
)

drop table test

a msg will throw...


"Execution of user code in the .NET Framework is disabled. Enable "clr enabled" configuration option"

Because we have disabled clr option before.Now Run,


sp_configure 'clr enabled', 1
GO
RECONFIGURE
GO

above query again enable your clr. Now you can perform any DDL operation.

How To Make Money With Google Adsense Step By Step Guide

Money for nothing? Well, not quite—but close! Google’s AdSense is a revenue-sharing opportunity for small, medium and large web sites that places ads for goods and services that are relevant to the content of your site, targeted to the people who frequent your pages. In turn, you get paid a small amount when the ad is either displayed on your page, or clicked on. We'll show you some good ideas that added to your own, will help increase your AdSense revenue